I created a new Rails 4.2 project, set up the Sequel Gem as per docs and ran the following command to set up my first section of the project:
rails generate scaffold Author nom_de_plume:string real_name:string email_address:string code_of_conduct_date:datetime created_at:datetime updated_at:datetime --orm=sequel
rake db:migrate
Based on reading on Stackoverflow and some Google links, my model skeleton looks like:
class Author < Sequel::Model
# ---
extend ActiveModel::Naming
include ActiveModel::Conversion
def persisted?
true
end
# ---
plugin :validation_helpers
plugin :after_initialize
# ---
def validate
super
validates_presence [:nom_de_plume, :real_name, :email_address, :code_of_conduct_date]
validates_unique([:nom_de_plume, :email_address]) end # def validate
# ---
def after_initialize
super
end # def after_initialize
end # class Author < Sequel::Model
The controller is stock / unmodified as yet. When I go to http://localhost:3000/authors/ everything works as expected.
However, when I click the http://localhost:3000/authors/new "New Author" link, I get the following error:
Showing /project/app/views/authors/_form.html.erb where line #1 raised:
No route matches {:action=>"show", :controller=>"authors", :id=>nil} missing required keys: [:id]
Extracted source (around line #1):
1 <%= form_for(@author) do |f| %>
2
3 <% if @author.errors.any? %>
4 <div id="error_explanation">
5 <h2><%= pluralize(@author.errors.count, "error") %> prohibited this author from being saved:</h2>
6
Clearly this is broken behaviour; "show" should not be getting invoked on a "new" request.
I created a new project, did not use the sequel-rails gem & associated configuration (using the default ActiveRecord), and the exact same code works as expected without errors.
I've spent a couple of hours doing searches, and cannot find a solution for this. I've wiped the project and restarted, and can reproduce the behaviour described consistently.
I know I could just drop sequel-gem and go back to AR, but I'd really rather not do so.
I'd appreciate a point in the right direction to getting this solved. Thanks in advance.
Just include some more ActiveModel sub-modules, full list here: