I recently stumbled across a very cool dialect of coffeescript called contracts.coffee. I want to use it in my rails project, but I'm unsure how I can modify the compilation options of coffee-rails. In order to compile the contracts I need to run:
coffee -c --contracts script.coffee
Is the best option here to build my own gem? Or is there someway to customize the compilation parameters in the coffee-rails gem?
There's a gem for that. So just add this to your Gemfile:
gem "contracts.coffee-source", "~> 0.3.1"
Related
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.
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.
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.
I have a problem with Activemessaging plugin and rails3 app.
my gemfile is
gem 'sqlite3'
gem 'activemessaging', :git=>'git://github.com/spraints/activemessaging.git'
gem 'stomp'
gem 'daemons'
After that activemessaging folder appeared in vendor
After bundle install I want to create processor with generator
rails generate processor Test
And I see this output:
ActiveMessaging: adapter reliable_msg not loaded: no such file to load -- reliable-msg
ActiveMessaging: adapter wmq not loaded: no such file to load -- wmq/wmq
ActiveMessaging: adapter beanstalk not loaded: no such file to load -- beanstalk-client
ActiveMessaging: no '/home/ruby/myapp/script/config/messaging.rb' file to load
ActiveMessaging: Loading script/app/processors/application.rb
Rails available: Adding dispatcher prepare callback.
ActiveMessaging: no '/home/ruby/myapp/script/config/messaging.rb' file to load
Could not find generator processor.
What did I miss ? What should I do step by step to make it works. Thank you
What guide or blog article are you using for installation?
http://code.google.com/p/activemessaging/wiki/Installation
Their wiki doesn't resemble the steps you're taking to install, since they recommend using it as a plugin.
EDIT:
After looking at their active issues on Google Code, this project doesn't support Rails 3 yet. At least, major features are missing such as all the generators being in the wrong place such that rails generate won't know about them.
If you want to go it on your own, you'll have to do a bunch of manual config:
http://code.google.com/p/activemessaging/wiki/Configuration
use https://github.com/kookster/activemessaging repo in your gemfile
gem 'activemessaging', :git => 'git#github.com:kookster/activemessaging.git'
Then you can use the rails 3 generators of this gem:
rails g active_messaging:install
rails g active_messaging:processor YOUR_PROCESSOR
This will create the config/broker.yml (broker config) and config/messaging.rb (queue config).
Its a very nice gem.
NOTE: Be sure to include the celluloid gem and daemons. In my gemfile:
gem 'stomp'
gem 'celluloid'
gem 'daemons'
Happy coding! .)
I'm developing a Rails3 engine application, and I want to use Haml for the views.
First, what I have done was to add this to the engine Gemfile:
gem "haml"
While I was testing my engine, it was working OK (I have used https://github.com/josevalim/enginex to generate the gem and test it with the dummy application).
My problems started when I tried to use the engine on a real Rails application. The application does not have gem "haml" on it's own Gemfile, and so it was not initializing Haml, so I was receiving template not found errors as it was not looking for the .haml views. I was thinking that by requiring Haml on the Engine it would be enought for it to be also required by the Rails application.
What I have done for now was to add a config/initializers/haml.rb on the engine with this code:
require 'haml'
Haml.init_rails(binding)
It's working now, but I'm wondering if this is really a good way to do it.
Why Rails is not calling Haml "init.rb" file and so initializing Haml correctly by just adding gem "haml" to the engine Gemfile?
Two things are necessary. First, in the .gemspec:
s.add_dependency 'haml', ['>= 3.0.0']
And in your lib/gem_name.rb:
require 'haml'
And then run bundle both inside the gem and app directories.
I think you will have to put haml in the engine gemspec as a dependency in order for bundler to install haml in the target application (and show up in its Gemfile.lock). Something like this:
Gem::Specification.new do |s|
s.add_dependency(%q<haml>, [">= 0"])
end
I just tested this out on one of my engines. Without the dependency in the .gemspec it did not install haml in the target app (did not appear in Gemfile.lock). After I added haml to the gemspec as a dependency, it does show up:
PATH
remote: /rails_plugins/mine/my_engine
specs:
my_engine (0.0.0)
formtastic
haml
inherited_resources
settingslogic
sqlite3-ruby
GEM
remote: http://rubygems.org/
specs:
#................
haml (3.0.25)
#................
If you are using jeweler, it will add the dependencies to the gemspec automatically based on what is in your Gemfile.. it even adds a developement_dependency if you have the group defined in your Gemfile. I have only looked at enginex briefly, so I don't know if it has a similar rake task to build the gemspec.
This might help clarify some things:
http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/