Hi all, I''ve the following doubt.
I''ve this controller methods:
def set_elaborator
@entry = Entry.find(params[:id])
@entry.geomatics_elaboration_id = current_user.id
if @entry.save!
redirect_to(@entry, :notice => ''Elaborator setted
successfully'')
end
end
def set_reviewer
@entry = Entry.find(params[:id])
@entry.geomatics_checker_id = current_user.id
if @entry.save!
redirect_to(@entry, :notice => ''Elaborator setted
successfully'')
end
end
So, I want to add a link in the show view, like this:
<p>
<b><%= t(''entries.fields.geomatics_elaboration'')
%>:</b>
<% if @entry.geomatics_elaboration_id.nil? and current_user.geomatics
%>
<%= link_to entry, :confirm => ''Are you sure?'',
:method =>
:set_elaborator do %>
<img src="../images/buttons/Delete.png"
title="Elaborate this
entry"/>
<% end %>
<% elsif @entry.geomatics_elaboration_id.nil? and not
current_user.geomatics %>
<%= t(''entries.messages.not_assigned_yet'') %>
<% else %>
<%= User.find(@entry.geomatics_elaboration_id).fullname %>
<% end %>
</p>
<p>
<b><%= t(''entries.fields.geomatics_review'')
%>:</b>
<% if @entry.geomatics_checker_id.nil? and current_user.geomatics %>
<%= link_to @entry, :confirm => ''Are you sure?'',
:method =>
:set_reviewer do %>
<img src="../images/buttons/Delete.png" title="Review
this entry"/>
<% end %>
<% elsif @entry.geomatics_checker_id.nil? and not current_user.geomatics
%>
<%= t(''entries.messages.not_assigned_yet'') %>
<% else %>
<%= User.find(@entry.geomatics_checker_id).fullname %>
<% end %>
</p>
I want to, when I click the link update the @entry and load the show
template with the changes...
Any suggestion?
Regards,
--
TSU. Amador Cuenca
--
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 7 February 2011 17:32, Amador Antonio Cuenca <sphi02ac-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, I''ve the following doubt. > I''ve this controller methods: > def set_elaborator > @entry = Entry.find(params[:id]) > -deMMSWxJ8CoamI4nPzzunQ@public.gmane.org_elaboration_id = current_user.id > if @entry.save!This should be save, not save!. save! generates an exception if it fails rather than returning false.> redirect_to(@entry, :notice => ''Elaborator setted successfully'') > end > end > def set_reviewer > @entry = Entry.find(params[:id]) > -deMMSWxJ8CoamI4nPzzunQ@public.gmane.org_checker_id = current_user.id > if @entry.save! > redirect_to(@entry, :notice => ''Elaborator setted successfully'') > end > end > So, I want to add a link in the show view, like this: > <p> > <b><%= t(''entries.fields.geomatics_elaboration'') %>:</b> > <% if @entry.geomatics_elaboration_id.nil? and current_user.geomatics %> > <%= link_to entry, :confirm => ''Are you sure?'', :method => > :set_elaborator do %> > <img src="../images/buttons/Delete.png" title="Elaborate this > entry"/> > <% end %> > <% elsif @entry.geomatics_elaboration_id.nil? and not > current_user.geomatics %> > <%= t(''entries.messages.not_assigned_yet'') %> > <% else %> > <%= User.find(@entry.geomatics_elaboration_id).fullname %> > <% end %> > </p> > <p> > <b><%= t(''entries.fields.geomatics_review'') %>:</b> > <% if @entry.geomatics_checker_id.nil? and current_user.geomatics %> > <%= link_to @entry, :confirm => ''Are you sure?'', :method => > :set_reviewer do %> > <img src="../images/buttons/Delete.png" title="Review this entry"/> > <% end %> > <% elsif @entry.geomatics_checker_id.nil? and not current_user.geomatics > %> > <%= t(''entries.messages.not_assigned_yet'') %> > <% else %> > <%= User.find(@entry.geomatics_checker_id).fullname %> > <% end %> > </p> > I want to, when I click the link update the @entry and load the show > template with the changes... > Any suggestion?You have shown much too much detail and made the question too complicated. Extract the fundamental question and demonstrate the problem with a *few* lines of code if necessary. Colin -- 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.
Ok Let''s try: I want to update a especific field from a show view when I click the "Set reviewer" link (assigning the current user ID), reload the same view and see the changes. Fields: *Entry.geomatics_checker_id *User.id. I hope you can upderstand now. (Sorry for my bad english :/ ) Regards, -- TSU. Amador Cuenca -- 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 7 Feb 2011, at 17:32, Amador Antonio Cuenca <sphi02ac-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, I''ve the following doubt. > > > <% if @entry.geomatics_checker_id.nil? and current_user.geomatics %> > <%= link_to @entry, :confirm => ''Are you sure?'', :method => :set_reviewer do %>Method (in this context) refers to an http method, i.e. get,post,put and so on Normally to do what you''re trying you''d add a route for that action to config/routes.rb, and then you can call some_action_entry_path(entry) to get the path to link to Fred> <img src="../images/buttons/Delete.png" title="Review this entry"/> > <% end %> > <% elsif @entry.geomatics_checker_id.nil? and not current_user.geomatics %> > <%= t(''entries.messages.not_assigned_yet'') %> > <% else %> > <%= User.find(@entry.geomatics_checker_id).fullname %> > <% end %> > </p> > > I want to, when I click the link update the @entry and load the show template with the changes... > > Any suggestion? > > Regards, > -- > TSU. Amador Cuenca > -- > 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.-- 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.