Reputation: 5148
I try to do the Getting Started with Rails tutoriel and I have a problem I don't understand..
I trying to do the part 5.10 Adding Some Validation with the update function but i have an error "We're sorry, but something went wrong." and nothing else...
I'm sorry for all the code, but i'm a begginer and i realy don't know where is the error :/
The controller :
class ArticlesController < ApplicationController
def index
@articles = Article.all
end
def new
@article = Article.new()
end
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
def show
@article = Article.find(params[:id])
end
def edit
@article = Article.find(params[:id])
end
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end
private
def article_params
params.require(:article).permit(:title, :text)
end
And if i delete the if/else/end on the update function, it's work (put an other error but not only the sorry message)
-----------------[ EDIT ]--------------------
I have read the log file and I think this line can help you :/
Started GET "/articles" for 127.0.0.1 at 2014-05-22 14:06:02 -0400
SyntaxError (C:/Users/Stephane/Desktop/rails_projects/fist_app/app/controllers/articles_controller.rb:32: invalid multibyte char (US-ASCII)
C:/Users/Stephane/Desktop/rails_projects/fist_app/app/controllers/articles_controller.rb:32: syntax error, unexpected $end, expecting keyword_end
else
^):
Upvotes: 0
Views: 803
Reputation: 117
You probably have an invisible control character in your text (perhaps from cut and paste). Try deleting the if/else statement and retype it by hand. I know this sounds strange but have seen this kind of thing happen many times.
Upvotes: 1