Can you do f.send in a form? I have questions and the data type stored in a db. <% Question.all.each do |question| %> <div class="control-group"> <%= f.send(:label, question.name), :class => ''control-label'' %> <div class="controls"> <%= f.send(question.data_type.to_sym, :question, :name) %> - <%= '' allergic to shellfish?'' %> </div> </div> <% end %> -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/6K79gq2KHPYJ. For more options, visit https://groups.google.com/groups/opt_out.
Of course! Are you encountering any problems with that? Dheeraj Kumar On Tuesday 31 July 2012 at 3:31 AM, Me wrote:> Can you do f.send in a form? I have questions and the data type stored in a db. > > <% Question.all.each do |question| %> > <div class="control-group"> > <%= f.send(:label, question.name (http://question.name)), :class => ''control-label'' %> > <div class="controls"> > <%= f.send(question.data_type.to_sym, :question, :name) %> - <%= '' allergic to shellfish?'' %> > </div> > </div> > > <% end %> > > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/6K79gq2KHPYJ. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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 https://groups.google.com/groups/opt_out.
Is there something I need to do to the data_type to make it recognize it as a method? wrong number of arguments (3 for 0) <div class="control-group"> 48: <%= f.label question.name.to_sym, :class => ''control-label'' %> 49: <div class="controls"> 50: <%= question.data_type "person[person_question_ids][]", question.id, nil %> - <%= '' allergic to shellfish?'' %> 51: </div> 52: </div> On Mon, Jul 30, 2012 at 9:17 PM, Dheeraj Kumar <a.dheeraj.kumar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Of course! Are you encountering any problems with that? > > > Dheeraj Kumar > > On Tuesday 31 July 2012 at 3:31 AM, Me wrote: > > Can you do f.send in a form? I have questions and the data type stored in > a db. > > <% Question.all.each do |question| %> > <div class="control-group"> > <%= f.send(:label, question.name), :class => ''control-label'' > %> > <div class="controls"> > <%= f.send(question.data_type.to_sym, :question, :name) %> - > <%= '' allergic to shellfish?'' %> > </div> > </div> > > <% end %> > > -- > 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 > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/6K79gq2KHPYJ. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- > 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 https://groups.google.com/groups/opt_out. > > >-- *"In matters of style, swim with the current; in matters of principle, stand like a rock." Thomas Jefferson * -- 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 https://groups.google.com/groups/opt_out.
You can access the object by using f.object then you can do f.object.send here ''f.object'' return an instance of Question, but i think that whatever you are trying to do you are doing it wrong, can you elaborate in what you are trying to do? -- 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 https://groups.google.com/groups/opt_out.
On Monday, 30 July 2012 23:25:45 UTC-4, Me wrote:> > Is there something I need to do to the data_type to make it recognize it as a method? > > wrong number of arguments (3 for 0) > > <div class="control-group"> > 48: <%= f.label question.name.to_sym, :class => ''control-label'' %> > 49: <div class="controls"> > 50: <%= question.data_type "person[person_question_ids][]", question.id, nil %> - <%= '' allergic to shellfish?'' %> > 51: </div> > 52: </div> > > > >Wait, what? You posted the correct code in your original post, but this isn''t that code. Line 50 here is saying, "call the data_type method on the question object with these three parameters". The generated accessor doesn''t understand the parameters, and you get the error. If you want to call a method whose name is selected at runtime, you *need* to use send. --Matt Jones -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HtXEgsuq8MEJ. For more options, visit https://groups.google.com/groups/opt_out.
Been a while, I had the closing bracket in the wrong spot: send needs all the params, it was erroring on , if i put the closing bracket right after the data_type or name <%= person_question.send(question.data_type.to_sym, question.name, :class => ''text_field'') %> On Monday, July 30, 2012 5:01:42 PM UTC-5, Me wrote:> > Can you do f.send in a form? I have questions and the data type stored in > a db. > > <% Question.all.each do |question| %> > <div class="control-group"> > <%= f.send(:label, question.name), :class => ''control-label'' > %> > <div class="controls"> > <%= f.send(question.data_type.to_sym, :question, :name) %> - > <%= '' allergic to shellfish?'' %> > </div> > </div> > > <% end %> >-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/gR9GK0yFNKEJ. For more options, visit https://groups.google.com/groups/opt_out.