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... -- Posted via http://www.ruby-forum.com/.
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 -- Posted via http://www.ruby-forum.com/.
Ah! many thanks! ... mhh note to self need more books... and need to make a real cheat sheet -- Posted via http://www.ruby-forum.com/.
trip dragon wrote:> Ah! many thanks! ... > > mhh note to self need more books... and need to make a real cheat sheetYou need the following books: Programming Ruby - Thomas ("pickaxe") Ruby for Rails - Black Agile Web Development with Rails - Thomas, Heinemeier Hansson (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 -- Posted via http://www.ruby-forum.com/.
Wes Gamble 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. > > WesAlso 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''} -- Posted via http://www.ruby-forum.com/.
Reasonably Related Threads
- Sieve autoreply woes on test setup
- Redirecting mail gives 'mail forwarding loop' to the sender - calling for sieve help
- form_remote_tag :onsubmit not working.
- Error in anova(): objects must inherit from classes
- [PATCH 1/1] ocfs2-devel: trivial fix for s/migrate/migration/ in dlmrecovery.c, line 1121