Rails + Twitter Bootstrap -- btn-mini btn-small not changing size - ruby-on-rails

Looking to use an icon for a delete button in a table, as shown below:
<i class="icon-white icon-trash"></i>
If I paste this code into a plain html page within my rails application, the btn-mini and btn-small seem to have no effect.
When I preview this button on http://www.plugolabs.com/twitter-bootstrap-button-generator/ it appears as I would expect. Anyone familiar with why this may not be working? I do not have any custom css files loading, just the bootstrap.
Also, I am running
gem 'bootstrap-sass', '~> 2.0.4.0'
Thanks!

Take a look at bootstrap-sass source in here:
https://github.com/twbs/bootstrap-sass/blob/master/vendor/assets/stylesheets/bootstrap/_buttons.scss
The gem uses Bootstrap 3, so use:
.btn-xs instead of .btn-mini
.btn-sm instead of .btn-small
.btn-lg instead if .btn-large

I got similar problem and my solution was to change of gem. Have you tried to change your bootstrap gem? Check it out this one

Related

images in emails using roadie gem

I want to know how to show images in email by using roadie gem. Using roadie i'm able to inline my stylesheets but it's not showing images. I have tried both
<%= image_tag "pic.jpg" %>
and
<img src="pic.jpg"/> or <img src="assets/images/pic.jpg"/>
inside my mail template, but it's not showing any of the images. Any help?
It's been a long time since I asked this question and I was pretty new to rails development so didn't really know what I was doing wrong. Anyways so the issue is when we use image_tag helper or asset_path helpers for rendering images, it makes relative paths for that image(you can check it in firebug or some other tool) and they won't work inside emails or lets say on any other remote server (other than where the app is hosted)
Fix:
You can specify where your assets are hosted by:
config.action_controller.asset_host = 'http://your_server.com'
Quite old, but if somebody needs this...
Usually I use:
%img{:src => asset_url('/email/logo.png') }
also, as mentioned in the comments, be sure to have config.action_mailer.asset_host configured
example:
config.action_mailer.asset_host = "http://localhost:3000/assets/"

How to change a fixed layout on twitter bootstrap to fluid using ruby on rails

Im not sure on how to change my ruby on rails application to fluid. At the moment it is fixed using sass twitter bootstrap and im struggling on finding the right way to change the entire application to fluid.
Could someone please point me in the right direction thanks.
In order to use fluid layouts in Bootstrap you must do two things:
Replace .row classes with .row-fluid in your view templates.
Load the responsive layout css file.
If you are using SASS, and assuming you have an application.css.scss file, make sure it's set up the following way:
#import "bootstrap";
#import "bootstrap-responsive";
Finally, when using a fluid grid make sure inner columns always add up to a total of 12:
<div class="row-fluid">
<div class="span6"></div>
<div class="span6"></div>
</div>
You can use any number of columns as long as they always add up to 12.

Jquery doesn't work with jquery-rails gem

I did bundle and generate install and now I have the jquery's files instead of prototype
I can see from mozilla firebug that the jquery's files are included, however I can't use jQuery or $ functions, the app/mozilla console don't know them.
Any suggestions how to fix this?
I'm using jquery-rails 1.0.12 and rails 3.0.8
It would be great if you could give more details but here are some things you can try:
Make sure that when you view the page source you can see the jQuery files are included. I usually have <%= javascript_include_tag :defaults %> between the HEAD tags
You can test if everything is working by adding the following code:
$(document).ready(function() {
alert('hello world');
});
Hope this helps
Make sure the line below is commented out (in application.rb) and that you have restarted your server.
config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

How to make assets in SASS?

In Rails, when we include an image into the page we use image_tag helper, which generates <img> tag and adds ?nnnnn at the end of its url, so that every time an image is updated the old version would not be stuck in the cache on the client side. Same thing for SASS needed, but I can't find it in the documentation.
You should be using helpers provided by sass-rails gem https://github.com/rails/sass-rails, (scroll to Asset Helpers).
These helpers can be used from inside sass files any time you need to reference an asset (image/audio/video/font)
body{
background: asset_path($relative-asset-path, $asset-class);
}
Note: image_url("...") is not working on Rails 3.1.0.rc4 due to a bug, but you can still use asset_url and asset_path.
Using stylesheet_link_tag will do this for you, just the same as image_tag does. This also applies to JavaScript files linked in with javascript_include_tag.

Lightbox for rails?

Does anyone know of a good lightbox plugin for rails? I found redbox but it seems to be out of development.
Thanks!
-Elliot
I just use the regular Lightbox 2. Include all the appropriate javascript and stylesheets then :rel => "lightbox" on your links.
Here is example how to easily use lightbox in rails (v4 in my case):
1. Download from site: http://lokeshdhakar.com/projects/lightbox2/
2. Copy lightbox.js to app/assets/javascripts
3. Copy lightbox.css to app/assets/stylesheets
4. Rename lightbox.css to lightbox.css.scss.erb
5. Copy four img's to app/assets/images
6. Edit lightbox.css.scss.erb:
- All image paths replace with:
<%=image_path "close.png"%>
with proper image name.
Add a data-lightbox attribute to any image link to activate Lightbox. For the value of the attribute, use a unique name for each image. For example:
Image #1
Thats all.
Is there anything wrong with the jQuery version?
Jquery on Rails
http://railstips.org/2008/11/20/jquery-on-rails-why-bother
You can try lightbox2, don't know if there is any rails plugin to use it, but writing some helper functions shouldn't be that difficult.
You can use http://github.com/Lipsiasoft/lightbox
I would recommend rlightbox. It is a jquery UI plugin. It can be used for photos and videos and the documentation is pretty good
I wrote my own Rails wrapper to use Lightbox inside your existing Rails application.
Github: https://github.com/vernondegoede/lightbox-rails

Resources