I'm new to RoR development and I'm searching for suggestion for finding best community gems.
E.g. for authentication/authorization? Is devise a good component? https://github.com/plataformatec/devise
Is there any gem for produce a richer gui in views with easy?
In few words, an experienced RoR developer what gems he installs after creating a new app?
Regards,
Giacomo
To answer the question, Ruby Toolbox is a great resource for finding Ruby/Rails projects (both new and old) as well as comparing the relative popularity of gems providing similar solutions. While the active development culture behind Ruby is empowering for developers accustomed to reading and writing Ruby, I think many newer developers get overwhelmed with all the options.
With that in mind, for someone who is just beginning Ruby/Rails development, I'd suggest either rolling your own authorization/authentication system or following a tutorial that explains the process. You can find a great tutorial explaining the basic structure of a User model including authentication in Michael Hartl's Rails Tutorial
Likewise, understanding that Rails Views can be as simple as combining regular, old HTML, CSS, and Javascript with some Ruby variables is valuable without depending on the magic of something like Bootstrap.
This is always basic in nearly all my apps.
gem 'devise'
gem "friendly_id", "~> 4.0.1"
gem 'omniauth-facebook'
gem "devise_mailchimp"
gem 'twitter-bootstrap-rails'
gem 'dragonfly', '~>0.9.11'
gem 'will_paginate'
gem 'will_paginate-bootstrap'
gem "mysql2", "~> 0.3.11"
gem 'thin'
and more. You can also visit http://railscasts.com/ you will get more ideas there.
Yes devise is very good gem with a lots of options and flexible authentications .
see this https://github.com/plataformatec/devise/wiki/Example-Applications
For gui in views you can use bootstrap twitter gem. It is easy and you can quickly build your view.
The gem installed by developers is depend on their need. there are more tah 1300 gem available right now...
Keep coding.
What helped me a lot was viewing a bunch of Railcasts. You'll get a good overview of gems you might want to use.
You can check this rails style guides from bbatsov, it's a community-driven guide, there are many practices that people used every day.
Here is my gemfile
you can also look into ruby-toolbox
Related
I am writing a gem that can be used with both Sinatra and Rails, however, the gem dependencies are different based on which framework the developer is using the gem on.
If it's a rails app, we need 'sass-rails' and 'coffee-rails'
If it's a sinatra app, we need 'sass' and 'coffee-script'
Ideally bundler would just install the necessary gems based on which framework this gem is being loaded into, but I can't seem to figure out how to conditionally specify dependencies.
Any suggestions would be much appreciated.
I would suggest you not to do that. It would be hackish and unreliable.
What you can do however is divide and conquer! Build a generic version of your gem that is framework agnostic and only handles the logic, let's call it yourgem-core, then you can build two other gems based on that first one, called yourgem-rails and yourgems-sinatra.
It's much better, only logic and logic test in yourgem-core, only rails integration tests in yourgem-rails, only sinatra integration tests in yourgem-sinatra
You can use :group option in bundler.
Reference: http://bundler.io/v1.5/groups.html
I'm building an engine, and I want to use VCR and Webmock for testing.
The documentation within the Gemfile generated when an engine is created, seems to suggest that all an engine's gems should be loaded via gemspec, but the only options for this are add_dependency and add_development_dependency. If I use the latter, VCR and Webmock get loaded into my development environment, and I then have to explicitly disable Webmock in the development environment. I'd rather not do that as a host app may want these gems to work in development, and my engine disabling them may be unexpected.
The obvious solution would appear to be to use the engine's Gemfile:
group :test do
gem 'vcr'
gem 'webmock'
end
Is this the right way to load gems that are only used when testing an engine?
Are there any gotchas doing this?
One of the well known rails engines, rails_admin (https://github.com/sferik/rails_admin) uses that approach, so I believe it can be considered a good practice.
What's the load order for Rails app and Rails app's Rails Engines?
My guess is that the Rails app Gemfile is the determining factor for a gem being loaded or not loaded. This might be worth a try in a Rails test app.
I believe the answer is that there is nothing wrong with declaring in an engine's Gemfile, gems only used for testing and debugging the engine code. Further, I think the Gemfile template should be made less ambiguous, and have submitted a pull request to this effect:
https://github.com/rails/rails/pull/11881
I need the functionality provided by the rails_sql_views gem. However it looks like the last commit for this gem was made in 2010. Has this project been outdated by a new project? I'd like to find an active gem to use to get this functionality.
http://activewarehouse.rubyforge.org/rails_sql_views/
http://rubygems.org/gems/rails_sql_views
After further research here is a Rails 3 candidate for similar functionality:
https://github.com/bradphelan/Active-Illusion
This is a gem of this blog post:
http://xtargets.com/2011/08/02/tableless-views-with-active-record/
However this solution doesn't seem to be very popular.
schema_plus gem has create_view method that seems compatible (although I'm not familiar with rails_sql_views).
barancw, I needed this gem for our product using Rails 3.2.5, so I forked the repo and updated the necessary pieces. This gem is great for improving the performance of our large database queries, as it reduces the need to load objects into memory. I combined this gem with another optimization: Rails - given an array of Users - how to get a output of just emails?
https://github.com/ryanlitalien/rails_sql_views
Original documentation: http://rubydoc.info/gems/rails_sql_views/0.8.0/frames/index
Please keep in mind the docs are a bit outdated ("require_gem" has been replaced with "gem" and add the gem to your Gemfile as well).
I would like to write my own gem that helps me in my rails apps. It will also inculde some controllers that deliver html. So i need to test that in a browser (html/css/js).
Whats the best practice for that?
Now im using the echoe gem to build my gem (are there any better gems?).
rake install
switch to other tab
stop the rails app
start the rails app (so it has loaded the gem)
and then testing it, in a browser with good old refresh.
This is no fun. Can i do it more efficient somehow? Is it insane not to write tests for the ruby files?
You could use two resources to help you:
https://github.com/krschacht/rails_3_engine_demo
https://github.com/josevalim/enginex
This will help you creating a gem which will basically be an engine (enabling controller and views). The first link as great and helpful documentation.
The main principle is to code in a separate folder and add your 'gem' in local by doing gem ‘cheese’, :path => "../rails_3_engine_demo"
Once you feel ready, pack it with jeweller or bundler. Here is another link: http://sirupsen.com/create-your-first-ruby-gem-and-release-it-to-gemcutter//
Including the gem this way in your app will enable you to properly test it's behaviour.
jeweler:Opinionated tool for creating and managing Rubygem projects
I'm having trouble getting rubygems to work in my Rails app. Specifically, I'm trying to use the json gem, documented here: http://flori.github.com/json/ I can successfully use JSON.parse() in IRB and script/console but not in my rails app.
I know it's some combination of config.gem 'json' in environment.rb and other things, but can't find a good explanation anywhere.
Can someone give me a concise list of what is required to use this gem OR point me towards comprehensive documentation of using gems in Rails? thanks!
config.gem is used for gem dependency in rails and it does nothing more than telling rails that a gem is needed, and helping the user install the appropriate gem, etc (more details here: http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies)
however by installing a gem, it should be able to be used by the rails app automatically, if not, probably you can add require "json" into environment.rb or in an .rb files in the initializers folder?
Hope it helps =)
I solved it. There's decent documentation here: http://apidock.com/rails/Rails/Configuration/gem
Once you have used config.gem in environment.rb, you should not need to 'require' it later.
My problem was that I had not stopped and restarted the server! It worked in script/console because everything was getting reloaded every time.