rails-admin

How do I show unscoped models in Rails Admin?

眉间皱痕 提交于 2019-12-18 05:01:37
问题 I needed this myself, so here it is QA-style: By default, Rails Admin shows a model's default_scope. How do I get it to show every model completely unscoped? 回答1: Approach 1 If you only need to list the records you can use the scopes method to control which records are returned. The first array element is the default, so if you add the following to your initialiser: list do scopes [:unscoped] end you will see all records. Approach 2 If you want to do more than list models you can create a

Rails Admin - undefined method `' for using Carrierwave multiple upload

不羁的心 提交于 2019-12-14 03:59:23
问题 I can't edit some records in Rails Admin after do a multiple files upload using Carrierwave. I guess that did the correct config, when I upload the files everything goes well, but if I try edit after save the record that error happens: .log: 14:33:56 web.1 | Started POST "/admin/__better_errors/563c2613b62e459f/variables" for 127.0.0.1 at 2018-11-21 14:33:56 -0200 14:33:56 web.1 | Tag Load (0.6ms) SELECT "tags".* FROM "tags" INNER JOIN "projects_tags" ON "tags"."id" = "projects_tags"."tag_id"

where to put partials for rails_admin views

冷暖自知 提交于 2019-12-13 14:23:35
问题 I am trying to use a partial to customize my edit view in rails_admin. In config/initializers/rails_admin.rb I have: RailsAdmin.config do |config| config.model 'Album' do edit do field :promotion do partial :hello_world end end end end I have also tried the other syntax that can be found on the rails_admin wiki: RailsAdmin.config do |config| config.model 'Album' do edit do field :promotion do def render bindings[:view].render :partial => carrierwave.to_s, :locals => {:field => self, :form =>

Rails Admin: No edit, show, or delete buttons for Rails 4 app

为君一笑 提交于 2019-12-13 14:09:41
问题 Using rails_admin for a very basic Rails 4 application. However, whenever I open up the dashboard (mounted at '/admin'), I do not see the edit, show, or delete link buttons for each of my records. Interestingly, if I manually go to the show or edit routes (i.e. /admin/ products /1 or /admin/ products /1/edit) the page shows up just fine and works as expected. Is there a configuration to turn these links on? Thanks for your help. 回答1: I figured it out! It turned out to be a conflict with

How to hide Add new option in Rails Admin

末鹿安然 提交于 2019-12-13 11:37:45
问题 I am customizing Rails Admin : https://github.com/sferik/rails_admin , i need to disable/hide "Add new" option for some model. Any help will save lot time for me. Thanks in advance 回答1: I use the following to achieve this on a specific model. Hopefully, this helps: config.actions do new do except ['Some Model'] end end 回答2: The answer is in the configuration documentation for actions. By default, all actions are possible, including new . To customize the possible actions, in config.actions in

Devise: fetch and set locale from User model

强颜欢笑 提交于 2019-12-13 00:07:13
问题 I set the locale for every user in the User table. I followed these instructions to fetch the locale after the user logs in. It works until the user reloads the browser, then the standard locale (en) becomes active again. How can I keep the value of user.locale in the session? I'm using Rails_Admin, which means whilst I do have a User model, I don't have controller for the User model. # ApplicationController def after_sign_in_path_for(resource_or_scope) if resource_or_scope.is_a?(User) &&

How to modify rails_admin edit view

倾然丶 夕夏残阳落幕 提交于 2019-12-12 21:39:44
问题 I have a Contact class associated with User class as follows class Contact < ActiveRecord::Base belongs_to :users end In my edit I want to show a dropdown with list of user name as options that component should bind with contact.user_id . How to achieve this? 回答1: There are a number of ways to achieve this, here is one example. <%= f.select :user_id, Contact.all.collect{|c| [c.user.name, c.user.id]} %> This creates an array of contact.user.name and contact.user.id and submits the selected

Rails admin with Sorcery

血红的双手。 提交于 2019-12-12 11:50:25
问题 I'm trying to install the Rails Admin Gem using Sorcery for authentication instead of Devise. Rails admin does provide a hook that you can use to attach your own authentication method. Here is the example they provide in their docs (using warden): config.authenticate_with do warden.authenticate! :scope => :admin end config.current_user_method { current_admin } I'm guessing that inside the block I need to reference the before_filter that Sorcery uses to authenticate users, which would be

Rails Admin Customization: embed html view into dashboard

一世执手 提交于 2019-12-12 09:48:49
问题 We have removed the dashboard and the history from the rails admin starting page: Now we want to embed a google analytics page for users to see the dashboards from GA. This page consists of some simple HTML. QUESTION: How do you embed html pages in the Rails Admin Dashboard. 回答1: The answer was very simple, I needed to create the following file: views/rails_admin/main/dashboard.html.erb And this overwrites the standard dashboard, easy as that. Found the information here 回答2: I can provide a

Rails_admin custom action specify template name

為{幸葍}努か 提交于 2019-12-12 05:25:29
问题 My app is Rails 4.1 with rails_admin 0.8.1. I want to create custom action that only shows articles that belong to logged in user. If I were using regular Rails scaffolding I would just create a new action in articles controller and tell it to use index view. I registered the action properly in rails_admin.rb so it shows up. But how do I specify template_name in RA? I keep getting Missing template rails_admin/main/myarticles ... when I browse to http://localhost:3000/admin/article/myarticles