Reputation: 2324
I'm currently working on a project using Rails 3.2 and Active Scaffold. I've created a simple controller for one of my models that is coded thusly:
class StudentsController < ApplicationController
before_filter :authenticate_user!
active_scaffold :student do |conf|
conf.label = "Students"
conf.columns = [:last_name, :first_name, :age, :gender, :grade_level, :current_grade]
conf.create.columns = [:last_name, :first_name, :age, :gender, :grade_level]
conf.update.columns = [:last_name, :first_name, :age, :gender, :grade_level]
conf.columns[:current_grade].actions_for_association_links = [:show]
conf.columns[:current_grade].sort_by :sql => "grade_level"
conf.actions = [:list, :search, :create, :update, :show, :delete]
list.columns.exclude :customer_id, :grade_level
list.sorting = {:last_name => 'ASC'}
end
def conditions_for_collection
["customer_id = #{current_user.customer_id}"]
end
def before_create_save(record)
record.customer_id = current_user.customer_id
end
end
My problem is this: When I delete a record, I receive a message that states '$record_name can't be deleted'. Yet I find the record is in fact deleted if I refresh the page. Upon examining my log file I see an error message stating:
undefined method `as_marked=' for #<Student:0x0000000554c1d0>
I tried adding :mark to my list of actions and that does solve the problem. However, I don't want a mark/checkbox column to show up in my list.
Any ideas? This is my first time using active scaffold, and I find this... annoying.
Upvotes: 1
Views: 400
Reputation: 2324
I've discovered that if I add this to my model:
def as_marked= (x)
end
it works, without showing a mark/checkbox column in my list.
For the record, I hate this solution :) If I come up with anything better I'll make sure to come back and update this answer.
Upvotes: 1