I want to create text box but in run time

I want to create text box but in run time

when I write in the controller for @a="input type =‘text’ "
and in the view <%[email protected]%> it display text box in the page when it run

but when I write in the controller for @a="<%=text_field%>"
and in the view <%[email protected]%> it doesn’t display text box in the page when
it run

how can i solve it

There are two problems with that. One, all that’s going to do is output
the text “text_field” not call the method. Second, text_field requires
two arguments object_name and method.

So anyway, use the send method to call the text_field method in the view
and pass in whatever args you need.

Controller

@a = ‘text_field’

View

<%= send(@a, :object_name, :method) %>

Hope that helps.

– Josh
http://iammrjoshua.com

mahmoud_cs wrote:

I want to create text box but in run time

when I write in the controller for @a="input type =‘text’ "
and in the view <%[email protected]%> it display text box in the page when it run

but when I write in the controller for @a="<%=text_field%>"
and in the view <%[email protected]%> it doesn’t display text box in the page when
it run

how can i solve it

On Dec 15, 2:31 am, Joshua A. [email protected]
wrote:

View

<%= send(@a, :object_name, :method) %>

Hope that helps.

– Joshhttp://iammrjoshua.com

unfortunately it didn’t work
it display that error undefined method ` text_field ’

text_field_tag

See:

http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html

How about creating a hidden DIV that include the text box, and make it appears programatically.


Regards,...


Ahmed Abdelsalam



hyuan wrote:

text_field_tag

See:

http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html

On Dec 15, 12:52 pm, mahmoud_cs <[email protected]>
wrote:

On Dec 15, 2:31 am, Joshua A. <[email protected]>
wrote:
</pre>
<blockquote type="cite">
  <pre wrap="">There are two problems with that. One, all that's 

going to do is output
the text “text_field” not call the method. Second, text_field requires
two arguments object_name and method.




So anyway, use the send method to call the text_field
method in the view
and pass in whatever args you need.



# Controller
@a = ‘text_field’



# View
<%= send(@a, :object_name, :method) %>



Hope that helps.



– Joshhttp://iammrjoshua.com


unfortunately it didn’t work
it display that error undefined method ` text_field ’
  

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs