So you are going to have one text field that gathers membercode? And
associated with the membercode are going to be a bunch of bottons, each
that will provide some controller action on membercode. Will the action
always be def create?
You have your recover_letter_rpts_path(:membercode). I am assuming that
this path as defined in your router.rb and leads to controller action
'create'. Run rake routes and show us the result, or copy/paste your
route.rb here.
Don't understand: "And there is no form to contain these fields." Plural
fields. These fields?:
<%= label_tag :"Enter member code" %>
<%= text_field_tag :membercode%>
<%= button_to "Death/Retired Recovery Letter Printing",
recovery_letter_rpts_path(membercode: membercode) %>
Are you saying that this code is not contained in a form...? Otherwise,
show us the form tag.
Is membercode being returned in your params? Have you been able to
capture that param in your controller?
Pending your answers to the above, a possible solution is this...
If all buttons lead to def create...
Go to your router and modify recover_letter_rpts_path(:membercode). Add
a new parameter, let's call it :process. Then for the above button, you
could rewrite it as..
<%= button_to "Death/Retired Recovery Letter Printing",
recovery_letter_rpts_path(membercode: membercode, process:
'verify_existence') %> I'm not sure about the best syntax for adding a
second parameter
In your controller
def create
membercode = params[:membercode] ## should verify existence (blank?)
of params[:membercode]
membercode_process = params[:process] ## should verify existence
(blank?) of params[:process]
if membercode_process == 'verify_existence'
member_exist = Member.find_by_member_code(membercode) ## pretty
sure that 'exist' is a deprecated method in Rails 2. I'd use something
like member_exist
respond_to do |format|
if member_exist.blank?? ## blank? is more thorough, it
tests for object.nil? || object.empty?
## puts is usually done for debugging purposes, do you want
to provide this information to your user? If so, you may want to put this
content into a partial -- depending on how elaborate your messages become
-- which will be rendered in recoveries_path.
### Or you could store it in flash, which will be presented
in recoveries_path
puts "******************************************"
puts "This is the member code #{membercode}" # done
puts "******************************************"
redirect_to(recoveries_path)
else
puts "This is the NO member code #{membercode}" ## Same as above
redirect_to(recoveries_path)
end
elsif membercode_process == 'some_other_process'
etc.....
end
end
end
If all buttons don't lead to def create... then create a new route path for
each.... But I think that folks here will have better suggestions in that
case.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/d7c4f024-5f7b-4d92-96ee-63c2be113a9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.