I know this may be a very basic question, but confusing me. If I write the following for example in the controller: @x = App.new(params[:x]) I know that I''m trying to create a new object here, but how can I read the params[:x] part. I know also that "params" is a Hash table in the controller, but what is the following statement trying to say when passing [:x] to params? What is this value? From where will I retrieve it? Thanks. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
SW Engineer wrote:> I know this may be a very basic question, but confusing me. > > If I write the following for example in the controller: > > @x = App.new(params[:x]) > > I know that I''m trying to create a new object here, but how can I read > the params[:x] part. > > I know also that "params" is a Hash table in the controller, but what is > the following statement trying to say when passing [:x] to params? What > is this value? > From where will I retrieve it?Do you understand how hashes (not "Hash tables"!) work in Ruby? If not, go read the Pickaxe book or other basic reference, then come back if you have further questions. Or are you asking where the params hash gets assigned to in the first place? If so, then that''s done by the Rails framework. I believe the Rails Guides will tell you more about that.> > Thanks.Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks @Marnen. I''m asking just how to read this: @x = App.new(params[:x]) Like saying, "Create a new object..........". -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 September 2010 21:49, SW Engineer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thanks @Marnen. > > I''m asking just how to read this: > > @x = App.new(params[:x]) > > Like saying, "Create a new object..........".Create a new App object, passing params[:x] to the initialize method. As Marnen said this is very basic Ruby. Get the Pickaxe book and work through it. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Please quote when replying. SW Engineer wrote:> Thanks @Marnen. > > I''m asking just how to read this: > > @x = App.new(params[:x]) > > Like saying, "Create a new object..........".And I pointed you to where you can find the answers. Was the information in those sources insufficient? If so, what part is still problematic for you? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks a lot. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 27, 9:49 pm, SW Engineer <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thanks @Marnen. > > I''m asking just how to read this: > > @x = App.new(params[:x]) >params[:x] means (assuming that params is a Hash) get the value for the key :x Fred> Like saying, "Create a new object..........". > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
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 via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 September 2010 22:10, SW Engineer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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?_Please_ go and read up on Ruby and go through some basic Ruby tutorials. Then you will look back on the question you asked and be embarrassed that every time someone googles and comes across it they will think how silly it is. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 27, 5:10 pm, SW Engineer <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.