Rails 3 simple custom post action for form -


i'm bit stuck actionview::missingtemplate error on form controller action doesn't require view since it's passing off params data controller , controller post api request.

# newsletter controller  def index end  def subscribe   gibbon.list_subscribe({:id => "my-list-id", :email_address => params[:email]}) end 

in routes:

# routes match "/subscribe", to: "newsletter#subscribe", :via => :post 

view form lives

# newsletter/index.html.erb <%= form_tag subscribe_path, class: "form", remote: true %>     <%= text_field_tag :email, nil, :class => 'email', :type=>"email", :placeholder => 'sign newsletter' %>     <%= submit_tag "go", class: "submit-button"%> <% end %> 

from newsletter index page there form , want send request of user's email address subscribe action

error:  started post "/subscribe" 127.0.0.1 @ 2013-04-20 18:01:02 +1000 processing homecontroller#subscribe js   parameters: {"utf8"=>"✓", "authenticity_token"=>"zsetnfgi5151hk7fihqh5/l536hc9/kdarf57352y=", "email"=>"test-user@email.com", "commit"=>"go"} completed 500 internal server error in 1836ms  actionview::missingtemplate (missing template home/subscribe, application/subscribe {:locale=>[:en], :formats=>[:js, "application/ecmascript", "application/x-ecmascript", :html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :coffee]}. searched in:   * "/code/myapp/app/views" ): 

the above error i'm receiving. wanted know how pretend template issue since action doesn't require view.

thanks help.

you can try

def subscribe   if request.post?     gibbon.list_subscribe({:id => "my-list-id", :email_address => params[:email]})     redirect_to root_url, :notice => 'success'   else     redirect_to some_place   end end 

in routes

post "/subscribe", to: "newsletter#subscribe" 

check routes double confirm


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -