rails-admin

rails admin column does not exist

﹥>﹥吖頭↗ 提交于 2019-12-11 06:55:59
问题 I'm getting a column does not exist when editing a user in rails admin. The relationship between sales and users is user has_many :sales, and sale belongs_to buyer and another belongs_to for seller, written out like belongs_to :seller, :class_name=>User, :foreign_key=>:seller_id ActionView::Template::Error (PG::Error: ERROR: column sales.user_id does not exist LINE 1: SELECT "sales".* FROM "sales" WHERE "sales"."user_id" = 14 ^ : SELECT "sales".* FROM "sales" WHERE "sales"."user_id" = 14): 1:

How to override value that appears in a dropdown in the rails_admin gem

筅森魡賤 提交于 2019-12-11 02:55:30
问题 I have a model UserDelegation that contains: belongs_to :delegator, :class_name => 'User'#, :conditions => {:order => 'users.last_name ASC, users.first_name ASC'} belongs_to :delegatee, :class_name => 'User', :touch => true#, :conditions => {:order => 'users.last_name ASC, users.first_name ASC'} and in my user model i have this: has_many :delegatees, :through => :user_delegatees, :order => 'users.last_name ASC, first_name ASC' has_many :delegators, :through => :user_delegators, :order =>

In rails_admin, how can I filter based on the presence of an association id?

爷,独闯天下 提交于 2019-12-11 02:34:47
问题 In rails_admin, I've got a list of cities. Some have a numeric state_id and some have a nil. I want my cities list view to let me filter based on whether that field is filled or blank. How can I do that? This raises an exception: config.model 'City' do list do filters [:state_id] ... ... because rails_admin can't find "city_id" among its list of "filterable fields", even though it's one of the displayed fields. 回答1: You have to set the field as filterable explicitly. config.model 'City' do

Add a default value for date field with rails_admin

╄→尐↘猪︶ㄣ 提交于 2019-12-11 00:19:49
问题 Using rails (4.2.10) and rails_admin (1.2.0) I am trying to addd a default date value to the confirmed_at field of the User Model. It works on the edit view but not on the new view. Here is my code : config.model 'User' do list do [...] end show do [...] end edit do field :confirmed_at do default_value DateTime.now end exclude_fields [...] end end 回答1: Try returning a string instead and format it using the same format rails admin uses for datetime fields. I believe it to be default_value I18n

RoutingError resulting from 'redirect_to root_url' not passing action

半世苍凉 提交于 2019-12-10 13:54:41
问题 With a standard install of Rails_Admin using Devise for authentication and CanCan for authorization, accessing http://localhost:3000/admin as a non-admin user produces the following server log: Started GET "/admin" for 127.0.0.1 at 2011-08-09 22:46:10 -0400 Processing by RailsAdmin::MainController#index as HTML User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 Completed 404 Not Found in 151ms ActionController::RoutingError (No route matches {:controller=>"gyms"}):

Using rails_admin with rails_api

泄露秘密 提交于 2019-12-09 09:37:44
问题 I originally posted this as an issue on rails_api GitHub, but am now posting it here due to inactivity. I'm trying to use rails_admin with a Rails 5 API application. I included extra ActionController modules up to the point that I can either have a functioning rails_admin panel or working API requests. The issue seems to be that rails_admin depends on ActionView::Layouts , which after included causes issues for API requests. Gemfile: gem 'rails', '>= 5.0.0.beta3', '< 5.1' ... gem 'rack-pjax',

undefined method page for #<Array:0xc347540> kaminari “page” error. rails_admin

回眸只為那壹抹淺笑 提交于 2019-12-08 20:57:33
i am using rails_admin. when i go to certain resource. by typin url localhost:3000/admin/rule than it give me this error. code is: scope = Rule.all scope.page(1).per(2) . above code is writtten in rails_admin gem.in a file named mongoid.rb placed in adaptors folder. complete log is: NoMethodError (undefined method `page' for #<Array:0xcea7408>): mongoid (2.4.8) lib/mongoid/criteria.rb:385:in `method_missing' /home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler/gems/kaminari-809105ad782a/lib/kaminari/models/mongoid_extension.rb:11:in `page' /home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler

Rails 4: Paperclip and rails_admin “undefined method `attachment_definitions' error”

强颜欢笑 提交于 2019-12-08 19:30:22
问题 I am using rails_admin and paperclip but installing rails_admin with a model having paperclip attributes has_attached_file throws an error undefined method `attachment_definitions' I am using Rails 4 and rails_admin at master git branch and protected attributes gem. 回答1: I am on rails 3 still but ran into the same issue. I am fairly certain its an issue with the latest paperclip and rails_admin. I backed paperclip down to paperclip (3.4.2) and everything works. Another thing of note I am

undefined method page for #<Array:0xc347540> kaminari “page” error. rails_admin

半世苍凉 提交于 2019-12-08 03:45:27
问题 i am using rails_admin. when i go to certain resource. by typin url localhost:3000/admin/rule than it give me this error. code is: scope = Rule.all scope.page(1).per(2) . above code is writtten in rails_admin gem.in a file named mongoid.rb placed in adaptors folder. complete log is: NoMethodError (undefined method `page' for #<Array:0xcea7408>): mongoid (2.4.8) lib/mongoid/criteria.rb:385:in `method_missing' /home/usman/.rvm/gems/ruby-1.9.2-p290@system/bundler/gems/kaminari-809105ad782a/lib

Source Reflection Errors with has_many :through

爷,独闯天下 提交于 2019-12-07 09:23:07
问题 I'm attempting to create a system where my site's users can favorites pages. Those pages have two types, either clubs or sports. So, I have four models, associated as such: User Model: class User < ActiveRecord::Base .. has_many :favorites has_many :sports, :through => :favorites has_many :clubs, :through => :favorites .. end Favorites Model: class Favorite < ActiveRecord::Base .. belongs_to :user belongs_to :favoritable, :polymorphic => true end Club Model: class Club < ActiveRecord::Base ..