开发者

No route matches "/subscribers/create"

开发者 https://www.devze.com 2023-02-14 15:34 出处:网络
I copied this from a book I\'m reading and I followed all the instructions but it\'s giving me No route matches \"/subscribers/create\" erro开发者_高级运维r:

I copied this from a book I'm reading and I followed all the instructions but it's giving me No route matches "/subscribers/create" erro开发者_高级运维r:

def create
    if request.post?
      @subscriber = Subscriber.new(:email => params[:email])
      if @subscriber.save
        @success = "Thank you, You have been subscribed."
      else
        @error = @subscriber.errors.full_messages[0]
      end
    end

Please note that the book is written for Rails v2 and I'm using v3.

What's wrong?


The code you posted is missing an END.

Also, no need to specify if request.post?

Rails will automatically route a POST request to the create method

0

精彩评论

暂无评论...
验证码 换一张
取 消