Hey guys i''m new to rails and had 2 easy questions. First i''m using a simple ajax feature and need to use a hidden variable for my values instead of the @ruby variables (example code below) <%= form_remote_tag :url => {:action => ''newlist'', :store => ''btc'', :today => ''02/25/2007''}, :update => ''mainfrm'', :complete => visual_effect(:bind_down, ''mainfrm''), :before => %(Element.show(''spinner'')), :success => %(Element.hide(''spinner'')) %> where i have :store => ''btc'', :today => ''02/25/2007'' - i need to use a hidden field id but can''t find much on the correct syntax for this. Can anyone help or point me to a good url? Second i need to figure out how to loop and display only select fields from my table instead of All the fields. <% for entry in @entries %><tr><% for column in Entry.content_columns %><td><%=h entry.send(column.name) %></td> Anyone on this? i''m sure it''s yet another newb question but i seem to be lacking some good google skills on this one also ... Thanks for the help if anyone replies -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Xavias wrote:> Hey guys i''m new to rails and had 2 easy questions. > > First i''m using a simple ajax feature and need to use a hidden variable > for my values instead of the @ruby variables (example code below) > > <%= form_remote_tag :url => {:action => ''newlist'', :store => ''btc'', > :today => ''02/25/2007''}, :update => ''mainfrm'', > :complete => visual_effect(:bind_down, ''mainfrm''), > :before => %(Element.show(''spinner'')), > :success => %(Element.hide(''spinner'')) %> > > where i have :store => ''btc'', :today => ''02/25/2007'' - i need to use a > hidden field id but can''t find much on the correct syntax for this. Can > anyone help or point me to a good url?You should be able to use the "hidden_field" form helper <%= form_remote_tag ... %> <%= hidden_field :post, :id %> </form>> Second i need to figure out how to loop and display only select fields > from my table instead of All the fields. > > <% for entry in @entries %><tr><% for column in Entry.content_columns > %><td><%=h entry.send(column.name) %></td>This is old scaffold code, which is a bit hard to read. You want something like: <% for entry in @entries %> <p>Title: <%= entry.title %> <p>Author <%= entry.author %> <% end %> Check out some of the beginner ruby on rails tutorials, or the book Agile Web Development with rails. Either will help you out a great deal. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
> <%= form_remote_tag ... %> > <%= hidden_field :post, :id %> > </form>what would the exact syntax be though? <%= form_remote_tag :url => {:action => ''newlist'', :store => ?, :today => ?}, :update => ''mainfrm'', :complete => visual_effect(:bind_down, ''mainfrm''), :before => %(Element.show(''spinner'')), :success => %(Element.hide(''spinner'')) %> i set the below hidden values dynamically <input type="hidden" name="hiddenstore" id="hiddenstore" value=""/> <input type="hidden" name="hiddendate" id="hiddendate" value=""/> -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Xavias wrote:>> <%= form_remote_tag ... %> >> <%= hidden_field :post, :id %> >> </form> > > what would the exact syntax be though? > > <%= form_remote_tag :url => {:action => ''newlist'', :store => ?, > :today => ?}, :update => ''mainfrm'', > :complete => visual_effect(:bind_down, ''mainfrm''), > :before => %(Element.show(''spinner'')), > :success => %(Element.hide(''spinner'')) %> > > i set the below hidden values dynamically > > <input type="hidden" name="hiddenstore" id="hiddenstore" value=""/> > <input type="hidden" name="hiddendate" id="hiddendate" value=""/>Do you want those variables to be in the url? or in the data from the form? If you want them in the form data then use hidden fields. <%= form_remote_tag :url => {:action => ''newlist''}, ...other options... %> <%= hidden_field_tag :store, my_spiffy_variable %> <%= hidden_field_tag :today, Time.now.to_s(:db) %> <%= other form fields %> </form> -- 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-/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 -~----------~----~----~----~------~----~------~--~---
I want them in the ajax form tag as params - but i am not sure of the syntax for this. <%= form_remote_tag :url => {:action => ''newlist'', :store => @store, :today => @today}, :update => ''mainfrm'', :complete => visual_effect(:bind_down, ''mainfrm''), :before => %(Element.show(''spinner'')), :success => %(Element.hide(''spinner'')) %> So instead of @store and @today up there i want to reference the hidden field so i can use the value set with some javascript dynamically. Is this possible? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Xavias wrote:> I want them in the ajax form tag as params - but i am not sure of the > syntax for this. > > <%= form_remote_tag :url => {:action => ''newlist'', :store => @store, > :today => @today}, :update => ''mainfrm'', > :complete => visual_effect(:bind_down, ''mainfrm''), > :before => %(Element.show(''spinner'')), > :success => %(Element.hide(''spinner'')) %> > > So instead of @store and @today up there i want to reference the hidden > field so i can use the value set with some javascript dynamically. > > Is this possible?So you want them in url the form posts to? Then you have the syntax right there. That form would post to: /some_controller/newlist?store=somestore&today=02-26-2007 Assuming you don''t have any custom routes, of course. If store and today are params in the url then you don''t need your hidden fields. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
I might be completely misunderstanding, but I believe he''s asking how to use the value from hidden fields that were posted to the current page... as in: <%= form_remote_tag :url => {:action => ''newlist'', :store => params[:hiddenstore], :today => params[:hiddendate]}, :update => ''mainfrm'', :complete => visual_effect(:bind_down, ''mainfrm''), :before => %(Element.show(''spinner'')), :success => %(Element.hide(''spinner'')) %> On 2/26/07, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Xavias wrote: > > I want them in the ajax form tag as params - but i am not sure of the > > syntax for this. > > > > <%= form_remote_tag :url => {:action => ''newlist'', :store => @store, > > :today => @today}, :update => ''mainfrm'', > > :complete => visual_effect(:bind_down, ''mainfrm''), > > :before => %(Element.show(''spinner'')), > > :success => %(Element.hide(''spinner'')) %> > > > > So instead of @store and @today up there i want to reference the hidden > > field so i can use the value set with some javascript dynamically. > > > > Is this possible? > > So you want them in url the form posts to? Then you have the syntax > right there. That form would post to: > > /some_controller/newlist?store=somestore&today=02-26-2007 > > Assuming you don''t have any custom routes, of course. If store and > today are params in the url then you don''t need your hidden fields. > > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
Luke Ivers wrote:> I might be completely misunderstanding, but I believe he''s asking how to > use > the value from hidden fields that were posted to the current page... as > in: > > <%= form_remote_tag :url => {:action => ''newlist'', :store => > params[:hiddenstore], > :today => params[:hiddendate]}, :update => ''mainfrm'', > :complete => visual_effect(:bind_down, ''mainfrm''), > :before => %(Element.show(''spinner'')), > :success => %(Element.hide(''spinner'')) %>I think Luke is the winner on this one guys - I only want to throw in the hidden value as a param but the issue is that it never seems to work. The example you have listed above runs but does not actually throw in the hidden date value. <form action="/entries/newlist?store=btc" method="post" ... This to me feels like something is not right here. I''m a .net developer during the day and wanted to play with rails on the side (and hope to convincee the evil M$ only dev team to start using ruby for some small things to start, etc) - sorry this seems so hard to communicate I use the below to manipulate the hidden value and this is why i want the form on submit to have this as the date param document.getElementById(''hiddendate'').value = formatDate(selectedDay,selectedMonth,selectedYear); So Luke if this is the correct syntax do you know why it does not include it in the action or onsubmit? I watch the above DOM change the value of the hidden in firebug but don''t see any change in the form action or onsubmit ... can''t figure out why this is so hard to figure out thanks for all the help on this guys -- 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-/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 -~----------~----~----~----~------~----~------~--~---
On thing to note about my above post - i''m not using the param[''hiddendate''] in the controller as a post param (so i might have communicated this incorrectly to Luke) but instead i need to use the actual value stored in the hidden field (because, as you can see above, i change this dynamically w/ some DOM(JS)) Any of this clear or what? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
So what you''re talking about is changing the place that the form submits whenever the hidden date field is changed? If I''m reading that correctly, then all you should really need to do is change your JS to be a function that does both what you are currently doing (set the hiddendate value) and ALSO updates that form to change where it is being submitted to... you could conceivably use observer_field here (it''s a Rails thing that allows you to make an ajax call if a field is updated) to observe the hiddendate field and then use AJAX to change the form''s submit url, but you''d be probably better off having your JS update both the hiddendate value, and the submit string for the form... this means you have to hardcode in that form''s submit, OR use some further JS to take whatever is generated by Rails and just modify the part of the string that contains the date=blah part. On 2/26/07, Xavias <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > On thing to note about my above post - i''m not using the > param[''hiddendate''] in the controller as a post param (so i might have > communicated this incorrectly to Luke) but instead i need to use the > actual value stored in the hidden field (because, as you can see above, > i change this dynamically w/ some DOM(JS)) > > Any of this clear or what? > > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
Luke i finally got the thing working - thanks for the help For all those who have looked at this post and thought "this kid is smoking crack" I have shown below what i was doing wrong (simple mistake that i''m not to proud of) @store = params[:store] @today = params[:hiddendate] <!-- it was @today = params[:today] --> i had to edit the @today in my controller - for some reason i didn''t edit this until I noticed the reply luke put up. on the html side i left what you had mentioned earlier <%= form_remote_tag :url => {:action => ''newlist'', :store => @store, :today => params[:hiddendate]}, :update => ''mainfrm'', :complete => visual_effect(:bind_down, ''mainfrm''), :before => %(Element.show(''spinner'')), :success => %(Element.hide(''spinner'')) %> And it works like a charm - thanks to everyone for the help. Big thanks to Luke for actually understanding my crazy request that was not communicated well. -- 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-/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 -~----------~----~----~----~------~----~------~--~---