Reputation: 10413
I just created a new app from scratch on rails4.0.0.rc1
with 1.9.3-p374
(which should work according to the guides).
However, I fail doing a simple create
-action.
class Books
def create
@book = Book.new book_params
if @book.save
redirect_to @book
else
render action: :new
end
end
private
def book_params
params.require(:book).permit(:name, :description)
end
end
Doing a create here results a
undefined method `synchronize' for nil:NilClass
with the error pointing to the line of if @book.save
.
Is that because of 1.9.3
or did I miss something?
Upvotes: 15
Views: 4354
Reputation: 10413
Apparently, It was failing because of the friendlyId gem. If you use friendlyId, you may need to specify the rails4-branch.
gem 'friendly_id', github: 'FriendlyId/friendly_id', branch: 'rails4'
edit: Make sure to get the actual branch/version from norman/friendly_id. According to the readme, it needs to be at least branch: 5.0.0-beta
to work with rails4.
edit2: now it is 5.0.0.rc2
, as I said, make sure to get the actual branch/version, I won't obviously update this answer every time there is a version update. Also, read the comments to this answer, there are plenty of helpful information.
Upvotes: 35
Reputation: 489
pduersteler's answer didn't work for me and failed with this error:
fatal: ambiguous argument 'rails4': unknown revision or path not in the working tree.
The README was update on Sep 23, 2013 with the following, which installed without error:
gem 'friendly_id', '5.0.0.rc2' # Note: You MUST use 5.0.0 or greater for Rails 4.0+
Upvotes: 3