Is there a way to remove just the boostrap media queries in my Rails app? I am unable to find the bootstrap.css file.
The bootstrap styles are located in the gem installation directory. You can find this directory by issuing the following command in your terminal and look for GEM_PATH:
gem env
Another way to find the gem path is by issuing
bundle show bootstrap
which will include the path of the gem installation.
Once you've located the path, copy the directory bootstrap from GEM_PATH/vendor/assets/stylesheets/ to your app/assets/stylesheets directory. I think the file you want to look at is app/assets/bootstrap/responsive.scss, at least this is where you want to start. Depending upon what you want to modify, modify the the content of this file.
Related
I've been following the guide around rails engines here: http://guides.rubyonrails.org/engines.html and have created the example engine blorgh and also have a barebones rails app.
I generated my engine following this command:
rails plugin new blorgh --mountable
And I can confirm that I have: /lib/blorgh.rb in my engine. Now going by the guides it states you simply need to add the following to your main app:
gem 'blorgh', path: 'engines/blorgh'. Now in my main rails app when I try to do bundle install I get:
The path /Users/home/projects/unicorn/engines/blorgh does not exist.
I'm pretty sure I'm missing something basic here.
The path /Users/home/projects/unicorn/engines/blorgh does not exist
Because Rails application going to Search ‘engines’ folder that's stores the engines (even if you just have one!) in your case /engines/blorgh not found any engine.
The path option in Gemfile is for using gem that is on the path specified.
And it have to be the directory where the unpacked gem is located.
In your case it looked to engines/blorgh relative to your working directory. Which is on /Users/home/projects/unicorn/engines/blorgh.
And /Users/home/projects/unicorn/engines/blorgh is simply doesn't exists.
To fix it, make sure you put the engine on /Users/home/projects/unicorn/engines/blorgh
I want to use one gem installed in system directory at a Rails project.For a certain reason, I cannnot add it to Gemfile and bundle install.Basicaly, I use bundler.
I want to do like this,
require 'gem_installed_in_vendor/bundle'
require 'gem_installed_in_system'
I wonder removing disable_shared_gems option help my hope,and I delete it from .bundle/config.But,it doens't work hopely.
output of bundle config is,
Settings are listed in order of priority. The top value will be used.
path
Set for your local app (/Users/my_name/works/thisApp/.bundle/config): "vendor/bundle"
and which gem's output is,
/Users/my_name/.rbenv/shims/gem
I want to read a .yml file included in a Rails Engine Gem from my main_app. The file is located at config/test.yml.
IO.read("config/test.yml") fails with No such file or directory # rb_sysopen
If i move the file into the main app, everything works fine. But i need this file in a Gem.
Solution 1
You can store the root path in a constant from your main gem file and retrieve it in other locations of your code. You must ensure that the gem got initialized before the code in your app runs otherwise you'll have an errors because the constant won't be defined.
# lib/my_gem.rb
GEM_ROOT = File.expand_path("../..", __FILE__)
# app/.../some_class.rb
IO.read("#{GEM_ROOT}/config/test.yml")
Solution 2
The most advisable, you can get the gem path programmatically from Bundler, then use that root path to retrieve the full path of your yml file.
Have a look at this answer that you can easily adapt to your case
You should be able to load app yaml files by doing this in your gem:
YAML.load_file('config/test.yml')
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.
I've read the documentation on the asset pipeline. It says assets will be looked up in the 3 asset locations and compiled into the public folder, but I don't see any javascript in any of the 3 locations in the new rails project that I have just created. I have run bundle install and the jquery rails gems is installed. But grep for "jquery" gives no such file. Where is jquery located?
They're located within the gem itself.