Including off-canvas layouts with the zurb-foundation Rails gem - ruby-on-rails

What is the right way of implementing the Foundation's off-canvas layouts in a Rails project?
I am using the zurb-foundation gem, and tried both version 3.x and 4 (with rails generators). The off-canvas js/css files do not seem to get included in my pages. Should I be including these manually?

Better late than never.
I just hade this issue and its due to the fact that the zurb-foundation gem is badly out of date.
Remove:
gem "zurb-foundation"
Run:
bundle clean -F
Add:
gem 'foundation-rails'
Run:
bundle install
And restart your server.

Related

rails plugin vs bundle gem

This two commands seem to generate practically the same thing
rails plugin new __name__
bundle gem __name__
There is a hidden detail I haven't notice?
which one do you use, and basically, why?
Thanks
They can all generate a barebone gem but they are different.
rails plugin new could generate a dummy app inside test, and a basic test_helper, which would be very handy if you want to add some functional/integration tests in gem. You can also revise that a bit to use Rspec. bundle gem would not do that.
If you develop the gem for Rails and need such tests, rails plugin would be better. Otherwise bundle or a gem generating gem jeweller.
Plugins are more or less deprecated in favor of gems in recent versions of Rails.
As far as I can tell, running rails plugin my_gem simply creates a 'my_gem' directory in the root of your rails app.
It's not too much different from running bundle gem my_gem except that it stubs out a couple of test files, and runs bundle install.
This may be useful if you're creating a gem that's made to be run on rails - where you need a "rails environment" (see the test/dummy/app directory).
Still, if you do it this way, it appears the gem is added right into the root of your rails project. You could always move it, but if you were to run bundle gem you could do so wherever you want.

Use gem as library in Rails 4

Is there a way to use a gem as a library in Rails 4?
I have tried putting in a gem folder after cloning into lib folder but this doesn't seem to be working
You can set local path to gem in your Gemfile if I clearly understood the problem.
# Gemfile
gem 'my_perfect_gem', path: './path/to/my_perfect_gem'
I think it's better to set local gem location only in development and test environments, so wrap this line in a group. Unfortunately you should restart your rails server any time you've updated the gem.
May be there is a better approach such as using your gem as a part of application in lib folder – Auto-loading lib files in Rails 4

Rails locations - where do I locate a gem

In Rails -
Where should I locate Gems? I downloaded bootstrap and it's working, as well as a sample Rails app, separately, but I want them to work together. There is a bootstrapped rails gem (http://rubygems.org/gems/bootstrapped-rails) which I downloaded, but I'm unsure as to where I should locate it. Under models?
And how do I make sure I am referring to it? I need to add something in controller as well?
Again, more an answer to the question in the title than to what was intended by the questioner but you can use
bundle show <gemname>
To locate the directory where a gem is installed.
As Dfr mentioned: https://github.com/seyhunak/twitter-bootstrap-rails
Twitter bootstrap isn't anything more than (mostly) a collection of css/js/image files.
Add this to your gemfile
gem "twitter-bootstrap-rails"
run
bundle install
run for simple css
rails generate bootstrap:install static
It should place relevant js and css files into your application.js and application.css files accordingly. (Read more about asset pipeline)
To get you started, in the gem's link under section - "Generating layouts and views", you can see rake tasks to generate sample layouts.
e.g.
rails g bootstrap:layout application fixed
You should now have a twitter-bootstraped application.html.erb file under views/layouts.
To answer the question in the title, you can locate your gems by running gem env in the console. That will give you the specific information about your "RubyGems Environment:" When you run gem install some_gem_name it will add this gem to your system.
However, what it sounds like your trying to do is add a gem to your app. If this is the case you add gems to a rails application's Gemfile.
So using your example, you'd locate your Gemfile and add the following:
gem "bootstrapped-rails", "~> 2.0.8.5"
Once that's done, you run bundle install in your terminal.
I find that a good resource for basic rails information can be found here: http://guides.rubyonrails.org/getting_started.html
The tutorial is short and it will give you a great starting point.

Rails does not load gems from vendor/gems

I have strange old buggy project on Rails 2.
It have gem's dependencies in config/environment.rb like
config.gem "andand"
config.gem "json"
config.gem "chronic"
config.gem "mini_fb"
all those gems are located in vendor/gems/
andand-1.3.3/
chronic-0.6.7/
json-1.7.3/
mini_fb-1.1.7/
rbet-1.0.3/
redis-3.0.1/
responsys_client-0.0.1/
but when i start unicorn server with this app it always complain that it can't find this gems. Why?
UPDATE
After building and installing gem from vendor/gems rails still complain about it.
I have tweake mini_fb gem into custom mini_fb_custom gem. Changed all references in gemspec and other files from mini_fb to mini_fb_my, installed it and it is shown in gem list as mini_fb_my. But it fails to load from config/environment.rb and complains that
Missing these required gems:
mini_fb_my >= 0
maybe i should rename lib/mini_fb.rb to lib/mini_fb_my.rb
i'll check it.
UPDATE 2
Yes, renaming files rocks!
You still need to install them from those folders, or unicorn will not know where to look for them.
Just install the gems from that directory and unicorn should pick them up.
UPDATE
You can install your gems locally with this command
gem install --local vendor/gems/gem/gem-name.gem
On more recent versions of rails you just specify path on the Gemfile
gem "gem-name", path: "path/to/gem"
My advice: replace the obsolete gem configuration with bundler (it works fine with rails 2, there should be a tutorial for rails 2 available on their website).
Configuration through gem command, freezing gems, etc. is just pain in the a** and it seemed kinda buggy to me when I'd used it (long time ago).

How to add a gem dependency and bundle install

Is it possible to add a gem dependency to a Rails 3 app programmatically through ruby code?
EDIT
I'm trying to achieve that when I launch a rake task or a ruby script my rails app becomes a sass rails app.
I have a bunch of file that needs to be copied and after that I'd like to add:
gem 'sass'
to my Gemfile and run bundle install automatically.
Today's railscasts features Guard!
One of the guard extensions is guard-bundler which has this code that can achieve what I need.
https://github.com/guard/guard-bundler/blob/master/lib/guard/bundler.rb
I thought that there was a way to perform similar tasks with the Bundler class.

Resources