NoMethodError in Admin::ApartmentPostsController#create

Home / Uncategorized / NoMethodError in Admin::ApartmentPostsController#create

Question:
I am using active admin for my admin panel in Ruby on Rails website. I have this code on my ApartmentPost resource.
ActiveAdmin.register ApartmentPost do
permit_params :title, :max_stay, :min_stay, :bed_configuration, :number_of_guests,:features, :description, :admin_user_id, :apartment_number,:latitude, :longitude, :clean_fee, :country, :location, photos: []

form(html: { multipart: true }) do |f|
f.inputs do
f.input :title
f.input :max_stay
f.input :min_stay
f.input :bed_configuration
f.input :number_of_guests
f.input :features
f.input :description
f.input :country
f.input :location
f.input :apartment_number
f.input :latitude
f.input :longitude
f.input :clean_fee
f.input :admin_user_id, as: :hidden, input_html: {value: current_admin_user.id}
f.file_field :photos, multiple: true
end
f.actions

end

So the error I am getting is while creating a new ApartmentPost. The error is:

I had created a column called rate in AparmentPost but now it is already removed. Still it gives this error.

Here’s the table from schema.rb:create_table "apartment_posts", force: :cascade do |t|
t.integer "admin_user_id", null: false
t.integer "max_stay", null: false
t.string "bed_configuration", null: false
t.integer "number_of_guests", null: false
t.string "features", null: false
t.string "description", null: false
t.json "photos"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "title", null: false
t.string "country", null: false
t.string "apartment_number", null: false
t.string "latitude"
t.string "longitude"
t.integer "min_stay", null: false
t.string "location", null: false
t.integer "clean_fee", default: 100, null: false
t.integer "property_type_id"
t.index ["admin_user_id"], name: "index_apartment_posts_on_admin_user_id", using: :btree
t.index ["property_type_id"], name: "index_apartment_posts_on_property_type_id", using: :btree

end

Here’s the code in routes.rb
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)

I am new in Rails and Active Admin. I tried searching the solution everywhere even tried uninstalling active_admin gem and installing again and removing apartment_post resource and generating it again but none og them worked. Please help me out. Thank you.


Answer:
You probably forgot to remove rate somewhere in your codebase. Try searching if you missed anything.
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *