I see => is a hash in ruby so is # , errrg But then I see in Rails
#=>
and then
render :action => ‘list.rhtml’
and other uses to it , I just need some sort of definition to what it
mean, is it redirect send_to ‘then’ no wait : is then , help…
I see => is a hash in ruby so is # , errrg But then I see in Rails
#=>
and then
render :action => ‘list.rhtml’
and other uses to it , I just need some sort of definition to what it
mean, is it redirect send_to ‘then’ no wait : is then , help…
trip dragon wrote:
I see => is a hash in ruby so is # , errrg But then I see in Rails
#=>
and then
render :action => ‘list.rhtml’and other uses to it , I just need some sort of definition to what it
mean, is it redirect send_to ‘then’ no wait : is then , help…
When creating a hash, => is used to relate the keys to the values.
Anywhere you see =>, a hash is being created. Lots of Rails methods
take hashes as input.
Wes
Ah! many thanks! …
mhh note to self need more books… and need to make a real cheat sheet
Wes G. wrote:
trip dragon wrote:
I see => is a hash in ruby so is # , errrg But then I see in Rails
#=>
and then
render :action => ‘list.rhtml’and other uses to it , I just need some sort of definition to what it
mean, is it redirect send_to ‘then’ no wait : is then , help…When creating a hash, => is used to relate the keys to the values.
Anywhere you see =>, a hash is being created. Lots of Rails methods
take hashes as input.Wes
Also you should know that hashes provided to method calls don’t always
need the {}'s around it to be a hash. For example, lets say I have a
method foo:
def foo(name, options = {})
puts “#{name} is #{options[:is]}”
end
Now as long the hash is the last element in the method arguments then
you can just string key/value pairs along as if they where individual
arguments:
foo(‘Sally’, :is => ‘hot’)
produces: Sally is hot
Which is exactly the same as:
foo(‘Sally’, {:is => ‘hot’})
So anytime you see a => remember its a hash and mentally put {}'s around
it. So in your example, render method excepts a hash.
render :action => ‘list.rhtml’
is the same as
render {:action => ‘list.rhtml’}
trip dragon wrote:
Ah! many thanks! …
mhh note to self need more books… and need to make a real cheat sheet
You need the following books:
Programming Ruby - Thomas (“pickaxe”)
Ruby for Rails - Black
Agile Web D. with Rails - Thomas, Heinemeier H. (2nd ed.)
[ optional: Rails Recipes - Fowler ]
plus a browser and a little patience, and you’ll be all set.
Good luck! It’s a lot of fun once you get into it.
Wes
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs