the correct return value of html_escape in example above
the correct return is:
Community contributions, tips, and corrections to the documentation. (1708 notes)
the correct return is:
An alternative to show relative paths is using the well known String#sub! method
base_dir = File.expand_path("my_dir") << "/" # don't miss adding "/"
files = Dir[File.join(base_dir, '**', '*.html.gz')]
p files.map {|f| f.sub!(base_dir,"")}
The path option will actually set the path and not the prefix I have found in Rails 3.0.5.
==== Example
resources :my_reports, :path => 'my-reports'
All actions for this resource will now be at /my-reports.
One thing to note about the code above is that it could have a security issue. If the user changes his/her password, the authentication token should expire. Hence, in a production scenario you should put in the password salt or something to allow the token to become invalidated.
this function will aways be followed by '.and_return(...)' because a stub is typically used for returning values. The required argument given to stub is a method name. When a message to this stubbed method name is received by a class or existing object of the class AND '.and_return' is provided, the...
==== Code example
Person.where(:name => 'David').exists?
If you're looking for mailer methods like "deliver" for rails 3 or later, you should look into "mail" gem: http://github.com/mikel/mail
To support multiple file selection simply pass :multiple => true in the options hash:
file_field_tag 'file', :accept => 'image/jpeg', :multiple => true
To test if an attribute is defined readonly:
class MyModel < ActiveRecord::Base
attr_readonly :important_type_thingie
end
#RSpec
describe MyModel do
its('class.readonly_attributes') { should include "important_type_thingie" }
it "should not update the thingie" do...
The second and third examples should exchange places to fit with their explanations.
==== Code
f = Tempfile.new(['graph','.json'])
==== Model
class ShareType < ActiveRecord::Base
has_many :shares, :dependent => :restrict
end
==== Controller class ShareTypesController < ApplicationController def destroy begin @share_type.destroy flash[:success] = "successfully destroyed." rescue...
in ruby 1.9 and afterwards, the to_enum and enum_for(synonym for to_enum) methods are buil-in to the language. so there's no need to require that any more.
FYI, It in Rails 2.1.1 the default value for :use_full_path has changed from true to false.
This will show up as an error stating "No such file or directory"
Basic usage example:
class User < ActiveRecord::Base
#...
skip_callback :create, :after, :send_welcome_email
#...
end
the 'symbol' parameter is not something specific like ':after_save', but rather ':save'
I suppose ':update' works as well.
fullpath includes request parameters in the result
Person.update(people.keys, people.values)
Will this request issue one or multiple queries to update the table data (as in http://stackoverflow.com/questions/3432/multiple-updates-in-mysql#3466 )
The answer is: it will do TWO queries per updated row. One select and one update.
As for me main difference between .dup and .clone , that first one doesn't not freeze result object if initial object was frozen.
In what appears to be a bug, there appears to be no way to use a custom error message when using this validator.