Hello im creating my first spree commerce and i did this
rails new spreecommerce
cd spreecommerce
i added this to Gemfile
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable'
rails g spree:install
rails s
now i can browse products and categories but /admin URL doesnt work.
so i tried
rake spree_auth:admin:create
but it says an error
rake aborted!
Don't know how to build task 'spree_auth:admin:create'
Im too wonder where are controllers and views located ? not in spreecommerce/ directory where i installed application, how can i edit that app ?
if i run rake routes in spreecommerce/ directory i can see admin route
admin admin/(.:format) spree/admins/orders#index
but i dont have spree directory in that folder ?
You'll need to run a bundle install after modifying your Gemfile. That should make the spree_auth rake tasks available.
The controllers and views are all stored in the Gemfile. You can execute bundle show spree_auth_devise to see where they are located on your system. Note that you should not modify those files directly, as those changes won't be able to be deployed to a different environment. You can refer to the Spree Developer Guide for more information on how to customize the controllers and views if you need.
Related
I'm new to Rails and I got a problem.
My new project requires rb-grib gem (link to ruby gems: https://rubygems.org/gems/rb-grib/versions/0.2.2). This gem requires GRIB API library, I installed it using brew install grib-api. It works in irb and .rb scripts. I need to use it in my Rails app, but I get an error LoadError: cannot load such file -- numru/grib. What I need to do to make it work and deploy to Heroku in future?
You need to add
require 'numru/grib'
i have two project,which one called A with Rails another called B just pure Ruby code.
when i call A controller actions named do_action it will call B rake tasks such rake dosomething
but i got error:
rake aborted!
cannot load such file -- pry
the gem pry in B Gemfile.
i want to know why rails project A will need B Gemfiles gems?
i think my linux env probelem? thk
Since you have call to rake dosomething to other's project from the specific (first) one, the environment gems will be applied from the first project. So, either:
add the pry gem dependency into the first project
generate the second project, which is in pure ruby, as a gem, and add it as a dependency into Gemfile of your Rails project as follows:
gem 'your_ruby_project_gem', :path => 'path/to/your/ruby/gem/project'
The way is for the projects, which are current under a development, i.e. the argument :path allows you to change the code under that path, so you gem will be also changed without reinstallation. Refer to more the bundler documentation. To run the Rails project you have to exec as follows:
bundle exec rails s
I prefer the second approach.
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.
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.
Is there any way to open file inside ruby gem that installed on heroku server ?
The gems will be the same as what you have defined in your Gemfile - that's the great thing about bundler..
bundle open gem_name