Hi guys, I''m a newbie in ruby and I would just like to know how you set a value for a field in a table where session[:user_id] matches user.user_id. I am trying to do this from a submit form in the show.html.erb file because that is where the other field value is set. Help would be much appreciated.. <p> <b>Title:</b> <%=h @post.title %> </p> <p> <b>Mood:</b> <%=h @post.mood %> </p> <p> <b>Location:</b> <%=h @post.location %> </p> <p> <b>Thoughts:</b> <%=h @post.thoughts %> </p> <h4>Comments</h4> <ul> <% @post.comments.each do |comment| %> <li> <%= h comment.comment %><br/> <div class = "dateline"> Posted on <%= comment.created_at.strftime("%B %d, %Y at %I:%M %p")%> </div> </li> <% end %> </ul> <% form_for(:comment, :url => post_comments_path(@post)) do |f| %> <p>Comment:<br/> <%= f.text_area :comment %></p> <%= comment.username.set("User.find_by_id(session[:user_id]).name") %> <%= f.submit "Create" %> <%end %> <%= link_to ''Edit'', edit_post_path(@post) %> | <%= link_to ''Back'', posts_path %> -- 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 11, 3:18 am, Evanoshki Brataslavainskinski <li...@ruby- forum.com> wrote:> Hi guys, > > I''m a newbie in ruby and I would just like to know how you set a value > for a field in a table where session[:user_id] matches user.user_id. > > I am trying to do this from a submit form in the show.html.erb file > because that is where the other field value is set.If I''ve understood you properly you''re doing this back to front. You''d typically do this in the comments controller, when you are creating the new comment -- 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.
is user.id no user.user_id On Sat, Sep 11, 2010 at 4:33 AM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Sep 11, 3:18 am, Evanoshki Brataslavainskinski <li...@ruby- > forum.com> wrote: > > Hi guys, > > > > I''m a newbie in ruby and I would just like to know how you set a value > > for a field in a table where session[:user_id] matches user.user_id. > > > > I am trying to do this from a submit form in the show.html.erb file > > because that is where the other field value is set. > > If I''ve understood you properly you''re doing this back to front. You''d > typically do this in the comments controller, when you are creating > the new comment > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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.