[Rails] Re: Very basic question
On Sep 27, 5:10 pm, SW Engineer <li...@ruby-forum.com> wrote:
> Thanks @Fred.
>
> Now, I'm getting it better.
>
> The last thing is, will the value be passed as a parameter to [:x] when
> creating a new object?
> --
> Posted viahttp://www.ruby-forum.com/.
This is both Rails basics and Ruby basics. 'params' is a hash and acts
like a hash. Here is a quick example from the console that I hope
helps but you would actually save time and learn more by reading up on
the subject:
>> params = {}
=> {}
>> params.class
=> Hash
>> params[:x] = 'SW Engineer'
=> "SW Engineer"
>> params.inspect
=> "{:x=>\"SW Engineer\"}"
>> puts params[:x]
SW Engineer
As you can see ':x' is the key to the value 'SW Engineer'. In Rails
that value would be coming from a field in your page called 'x'.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home