Ruby on Rails Wednesday, July 8, 2015

can't you do that using template?

2015-07-09 5:57 GMT+06:00 Padmahas Bn <padmahas@gmail.com>:
I have 

<%= label_tag :"Enter member code" %>
<%= text_field_tag :membercode%>

<%= button_to "Death/Retired Recovery Letter Printing", recovery_letter_rpts_path(membercode: membercode) %>


In my controller

def create
    membercode = params[:membercode]
    exist = Member.find_by_member_code(membercode)
    respond_to do |format|
      if exist.nil?
        # format.html{ redirect_to new_recovery_url, notice: 'Member not found.'} # here you just echo the result
        puts "******************************************"
        puts "This is the member code #{membercode}"  # done
        puts "******************************************"
        redirect_to(recoveries_path)
      else
        puts "This is the NO member code #{membercode}"
        redirect_to(recoveries_path)
      end
    end    
  end


all I want to do is send membercode which is accepted via text_field_tag to the create action of the controller. And there is no form to contain these fields. I want it that way because, there will be more "button_to" which want to send membercode to different controller's action.


Please help me.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9c16f865-e756-4e91-83ce-b5d101abdfee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
 Md. Sadaf Noor (@sadaf2605)
 www.sadafnoor.com

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAAJ2eVpYFGL92ZBx1bDLdSB91tahTSS2Q37a46R2uhfu_uZDwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment