I'm loving the rails_admin plugin from https://github.com/sferik/rails_admin but I cant for the life of me get my custom logo to replace the installed one.
Anyone have any insight as to how to achieve this? I've tried o开发者_如何转开发verriding the css and rails_admin directory/fil structure but it doesnt pick my changes up.
Anyone got any insight as to how to get this resolved?
if you want to do this now, there is a supported method - just override the title partial by creating a file at app/views/rails_admin/main/_title.html.erb
(or .haml or whatever).
Mine for instance contains:
%h1.title
= link_to rails_admin_dashboard_path do
= image_tag "design/admin_logo.png"
I suppose you just change the logo to put your logo in this place in your application :
public/images/rails_admin/logo.png
I don't know if this is right and if rails_admin author wants you too, but a dirty method is to go into your rails_admin gem and rename (or delete) assets folders so Rails don't find the Rack assets so it fallbacks on Rails ones that you've copied through :
rake admin:copy_assets
Then you just have to modify the ones in your app public directory.
I know it's kind of a hack and you'll have to do it again if you update the gem. And again, I don't know if it's a good advise since I don't know Rails Admin author's policy.
You can copy the /app/views/layouts/rails_admin folder, located in the gem installation folder (bundle show rails_admin), into your project's app/views/layouts folder. Then you can modify the _header.html.erb partial, on the line:
span class="image_replacement"><%= @plugin_name %>
Hope this helps
Another way to do this would be:
before_filter :if => Proc.new{ |c| c.request.path =~ /admin/ } do
@head_stylesheet_paths = ['admin_screen.css']
end
Then you override the image_replacement class with a bang important.
.image_replacement{
background-image:url(...) !important;
}
After digging around and asking on the rails_admin google group it appears that this functionality is not supported at the moment.
Replacing
public/images/rails_admin/logo.png
Should work as long as you also did this:
rake admin:copy_assets
As part of your install.
You can do it extremely easily with pure scss. Sometimes the simplest thing that could work will work :)
.navbar-inner {
background-image: image_url('logo.png');
background-size: auto $navbar-height; // put your own sizes here
background-repeat: no-repeat;
}
.brand {
display: none !important; //get rid of the text
}
精彩评论