1

I'm following the tutorial here and when I try to click the create article button in my web browser literally nothing happens, neither in the web browser nor the server console. The webpage renders correctly, it's just the button that isn't working. According to the tutorial I should be getting an error if the function 'create' wasn't defined in the ArticlesController class. Here is the template code:

<h1>Create a New Article</h1
<%= form_for(@article) do |f| %>
  <ul>
  <% @article.errors.full_messages.each do |error| %>
    <li><%= error %></li>
  <% end %>
  </ul>
  <p>
    <%= f.label :title %><br />
    <%= f.text_field :title %>
  </p>
  <p>
    <%= f.label :body %><br />
    <%= f.text_area :body %>
  </p>
  <p>
    <%= f.submit %>
  </p>
<% end %>

ArticlesController

class ArticlesController < ApplicationController
  def index
    @articles = Article.all
  end

  def show
    @article = Article.find(params[:id])
  end

  def new
    @article = Article.new
  end

end
11
  • Ensure that you've typed <%= f.submit %> and not <% f.submit %> Commented Dec 28, 2014 at 13:14
  • yeah I copy and pasted it straight from the text file, which was copied and pasted from the tutorial site. I see the button on the webpage and when i click it, it depresses, but nothing else happens Commented Dec 28, 2014 at 13:15
  • Confirming: clicking on submit doesn't change anything in the server window i.e. no request is sent? Commented Dec 28, 2014 at 13:16
  • Nope, nothing happens in the server window. Commented Dec 28, 2014 at 13:17
  • 1
    just tiny mistake.. u have not closed h1 tag "</h1>" Commented Dec 28, 2014 at 14:33

2 Answers 2

2

Just tiny mistake, you forgot to close h1 tag </h1>

Sign up to request clarification or add additional context in comments.

Comments

2

try add create action and private action, for example:

def create
  @article = Article.new(article_params)
  @article.save
end


private
  def article_params
    params.require(:article).permit(:title, :body)
  end

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.