Hi i need my params to use inside a <script> tag in the same .rhtml file. how do i access this. Anyone please......? Thanks -Sadeesh. --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Don''t know, what exactly you want to do... Have the params hash transformed to javascript variables? def variables_for_javascript(variables) variables.map {|k, v| "var #{k}#{'' = '' if v}#{v};"}.sort.join("\n") end something like this would do the trick in a helper could be easily adjusted to generate a js hash or whatever But you question isn''t detailed enough to give you any real help --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Thorsten, In my app, when user does a particular action, I want to show a greybox where the previous form element input values are needed. Here greybox is opened inside a script tag with specifying a url, in that url i need to pass the parameters that i got in this action. This is my real problem. I hope explained clear. Your previous example too a controller method. Then, how do i access it from inside a script tag. Looking for your valuable reply. Thanks, -Sadeesh kumar. On Jul 7, 5:01 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> Don''t know, what exactly you want to do... > Have the params hash transformed to javascript variables? > > def variables_for_javascript(variables) > variables.map {|k, v| "var #{k}#{'' = '' if v}#{v};"}.sort.join("\n") > end > > something like this would do the trick in a helper > could be easily adjusted to generate a js hash or whatever > > But you question isn''t detailed enough to give you any real help--~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---
If you just need thee content of a param, use <%= %> for example: <%= params[:user][:name] %> you can use this wherever you want inside rhtml, it doesn''t matter if the area is html or script. if you would want to use my helper, you would put the method in application_helper.rb or in the helper belonging to the controller and just call it like <%= variables_for_javascript(params[:user]) %> this would generate a list of vars from the users fields in the hash. eg: var name = somename note, that it''s not generating parentheses around strings, I''ve written it for a special purpose, but it could be adjusted easy enough. --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Really your answer cheers. I solved my problem. Thanks, for your quick and valuable reply. I queried another problem in http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/417bce6056e8f19a. But I got no reply. Do you have any idea? Please... Thanks, -Sadeesh kumar. On Jul 7, 5:37 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> If you just need thee content of a param, use <%= %> > > for example: > <%= params[:user][:name] %> > > you can use this wherever you want inside rhtml, it > doesn''t matter if the area is html or script. > > if you would want to use my helper, you would put > the method in application_helper.rb or in the helper belonging > to the controller and just call it like > > <%= variables_for_javascript(params[:user]) %> > > this would generate a list of vars from the users fields in the hash. > eg: > var name = somename > note, that it''s not generating parentheses around strings, I''ve > written it for a special purpose, but it could be adjusted easy > en ough.--~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---
I queried another problem> inhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/.... > But I got no reply. Do you have any idea? Please... >I''ve seen your post, but sorry no idea. I''ve never used this plugin and so no experience with it. And this kind of trouble, errors appearing sometimes can be very hard to debug. You would have to track down the exact circumstances, when it happens. Often it''s just an object that''s nil, when it shouldn''t be and then of course would not have this find_by_key function. First thing would be to know, if the error happens in one and the same controller/action all the time or in several places. Most likely you only use this in one controller anyway. Then you can post your code and the stack trace you get from the error. This may enable people to help you better, sometimes experienced programmers can tell you the source of trouble from the stack trace without knowing too much of the rest. It''s always difficult to find a good way to post questions in a forum like this. Too short and you miss information. Too long and nobody finds the time to read it. If you don''t get answers, try to supply more information, but at the same time try to keep it "compact" --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---
Thorsten, Thanks for your kind reply and big suggestions. I will follow your ideas hereafter. Thanks again, -Sadeesh kumar. On Jul 7, 6:24 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> I queried another problem > > > inhttp://groups.google.com/group/rubyonrails-talk/browse_thread/thread/.... > > But I got no reply. Do you have any idea? Please... > > I''ve seen your post, but sorry no idea. > I''ve never used this plugin and so no experience with it. > And this kind of trouble, errors appearing sometimes can be very hard > to debug. > You would have to track down the exact circumstances, when it happens. > Often it''s just an object that''s nil, when it shouldn''t be and then of > course would not > have this find_by_key function. > First thing would be to know, if the error happens in one and the same > controller/action > all the time or in several places. > Most likely you only use this in one controller anyway. > Then you can post your code and the stack trace you get from the > error. This may enable > people to help you better, sometimes experienced programmers can tell > you the source of > trouble from the stack trace without knowing too much of the rest. > > It''s always difficult to find a good way to post questions in a forum > like this. > Too short and you miss information. > Too long and nobody finds the time to read it. > If you don''t get answers, try to supply more information, > but at the same time try to keep it "compact"--~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---