What basic gems i need? [closed] - ruby-on-rails

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
hi im new to ruby on rails application development im just wondering what basic gems i need for my ruby on rails im a beginner and don't know what gems are important for a beginner like me
thanks please help

I agree with Dave (and certainly with Alex about railscasts!)
However it's good to know what's ahead and what's good to pick, so from experience I can recommend the following (when you are ready):
Initially:
rspec for testing. Get into testing asap!
authlogic for authentication. "Login"
simple_form for views. (Saves hair extraction ;) )
mysql2 for your database or just use sqlite
As needed:
heroku If you are deploying on heroku
resque for background tasks.
activeadmin for instant admin CRUD against tables.
Then (more experienced developer):
devise for authentication. Does everything.
cancan for user roles. Great options for simple roles.
haml for views. Popular approach for cleaner code by removing <'s and >'s and
ruby end's and html </closing> tags
pg for Postgres
You will also find this very helpful: https://www.ruby-toolbox.com/

I highly recommend pry -- it's unbeatable for exploring your code and data. In Rails it's a pleasure to use as a rails console replacement.
I also recommend a gem of a book (see what I did there?) called Rails AntiPatterns which will help you start writing clean Rails code. And The Rails Way, if you haven't already.
There are so many gems, that it's best to start looking only when you have an itch you assume someone else must have already scractched.

Before using any gems I'd recommend you to go ahead and run this code in your Console.
rails g scaffold Foo bar:string faz:integer
This will generate a whole bunch of files in your project.
Looking through the generated code helped me understand the fundamentals of a Rails application.
But to answer your question:
It really depends what functionality you want to add to your application.
I would also recommend to watch the Railscasts video tutorials. Ryan features a lot of gems and also explains and compares them to similar ones.

Generally I'd suggest picking up a good book
and working through it.
If Rails is what you're interested in, then check out;
Ryan Bigg's "Rails 3 in Action" (covers 3.1 in depth)
Sam Ruby / Dave Thomas / DHH's "Agile Web Development With Rails" (using rails 3.0)
Obie Fernandez' "The Rails Way"
They will introduce you to the design patterns and workings required to build apps in Ruby and Rails.
And consequently, along the way, you'll find out how and when to use various different gems.
Asking what gems to use, without a context doesn't really get you anywhere, unfortunately.

Related

Ruby and Rails or Ruby on Rails [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I understand Rails is a web framework built on Ruby. Ruby is a language separate from Rails which Rails uses. I'm not getting if it is best to use both separately or it is best to use Ruby on Rails.
Or is Ruby on Rails a completely different framework just using Ruby code and Rails code? Could you just install both Ruby and Rails and set them both up together?
If the above is true then what is Ruby on Rails and the benefits of using it in comparison to setting up Ruby and Rails as one?
RUBY => programming language
RUBY ON RAILS => web framework written in ruby
ROR / RAILS => shortcut for RUBY ON RAILS
is this still confusing?
The name "Ruby on Rails" is sometimes shortened as "Rails", or "RoR", which is the same - a web development framework.
You can, of course, use Ruby without Rails, as you can use any other programming language, to build different programs, not only web applications.
You cannot use Rails without using Ruby, because as you wrote yourself, Rails is a web framework built in Ruby. When you build web applications in Rails, you write your code in the Ruby language (there are some other rewrites of Rails, like GRails, which uses Groovy, but this is a different thing).
If you follow the installation guide on the Get Started page, you will see that you first install Ruby for your platform, then install RubyGems (which is a package manager for installing additional Ruby libraries), and then use RubyGems gem install rails command to install Rails with all its dependencies. So you might say that Rails is a library for Ruby.
This installation of Rails then provides a set of scripts, including the rails command, which help you build your web application according to the set of conventions adopted by Rails.
From http://guides.rubyonrails.org/getting_started.html:
Rails is a web application framework running on the Ruby programming language.
I highly recommend making your way through this guide.
Well, it seems many people don't know Ruby but they know Rails. Just as much as I know how to use JQuery without actually understanding JavaScript. So you're not completely off the trail asking this question :)
But honestly, it's not much fun just doing Rails without understanding Ruby. As soon as you understand Ruby you will see more to it than just Rails.
I'd recommend you get familiar with Ruby first and then see if you like the language. If you do you can go further and try Rails as well. If Ruby doesn't suit your language tastes try a different language like Java or Erlang or Python (whatever, doesn't really matter and - as always- depends on the problem you're trying to solve).
If you like Ruby you will also soon learn that there are other nice web frameworks like Sinatra that are a lot smaller and might fit your needs a lot better. Again, it depends on your needs.
Read up on some of the languages, mostly their web sites offer some insight into what they are like and what they are good for. Check http://ruby-lang.org for Ruby!
Ruby is an a language, and Ruby on Rails is an a webframework. It is more like C# and ASP.NET, Python and Django or Java and Spring. So everything what is possible with Ruby is posible with Rails and the other way, everything what is possible in Rails is possible in Ruby, but it can be harder, longer or less clear than using RoR.
Ruby on Rails is web development framework built using Ruby. So it borrows the syntax and some functionality. Ruby is programming language and it is not specific to domain. Ruby can be used in more than one domain. If you want to develop a web app you need to use Ruby on Rails. There are many web frameworks built on Ruby.
For knowing Rails you need to know basics of Ruby. So better to start Ruby first. Once you get the basics you can learn both parallel.
For Ruby refer: http://www.ruby-doc.org/docs/ProgrammingRuby/
For RoR refer: http://guides.rubyonrails.org/getting_started.html
Use RVM (Ruby Version Manager): to install. Link: https://rvm.io/rvm/install/

Ruby on Rails 3.1 Blog Engines

I see a lot of people asking about Blog Engines, but most of the questions & answers are rather old. Or if they aren't old most of the projects are old. I'm wondering if anyone knows of any Blog Engines that currently support Rails 3.1 or are at least being actively developed to support Rails 3.1.
I would also be interested in seeing any sample applications or blog posts written for Rails 3.1 Blogs. I am going to be adding a blog to one of my websites, and would prefer to simply use a Rails Engine or sample code if there are any good ones out there. I hate reinventing the wheel. Looking for something simple, and not too opinionated so I can modify easily to suit my own needs.
you might want to check out Refinery http://refinerycms.com/engines
doesn't look like they are 3.1 yet, but probably soon
https://github.com/resolve/refinerycms-blog
Your best bet would probably be to use Typo.
Typo is currently using rails 3.0.9. Rails 3.1.0 is still a release candidate so I don't know of any blogging apps using it right now. If you must use rails 3.1.0 then you may have luck grabbing the gem for 3.1.0.rc4 (the newest version) and using typo anyway. Chances are everything will still work.
Hope this helps.
Perhaps Enki is a good fit, currently at Rails 3.0 but there is a github branch with Rails 3.1 support.
http://www.enkiblog.com/
Interestingly BrowserCMS was recently made to be a mountable engine: https://github.com/browsermedia/browsercms/commit/6098699fed2e3dbd65815ac3a5ce0dd6acc103d2
Seem to have a bit of time and experience behind them. More akin to Concrete5 with an inline front end / in context editing facility for users, which can be a real plus.
Im looking into this now and Im getting to conclusion that the best way to do this would be mounting a rack-app(like sinatra) into your rails app, there's various basic sinatra blogs in github to start or copy, not to mention this is fully customizable and I guess very light-weight.. engines will likely have dependencies and may also break when updating gems, a rack app won`t
I wasn't able to find any satisfying solution with engines
other stuff I found:
mounting a rails app inside a rails app: http://blog.dynamic50.com/2010/02/22/rails-3-0-mount-multiple-apps-as-engines/ feels a bit weird(heavy?), but you could mount a fully featured app like enki...
http://planscope.io/blog/2012/03/08/mounting-a-blog-within-a-rails-3-application/ this blogpost talks about using Toto, it seems pretty nice, easy and simple... but the project is not being maintained and it doesn't seem to be able to support a lot of features...
I dunno about using git to post, it makes it really simple but I dunno if I'd like having non-code stuff in my commits
Monologue https://github.com/jipiboily/monologue . From their web:
It is a barebone blog engine for Rails. It is built as a Rails engine and with a focus on keeping very few dependencies to ease it's use in your project. You can also use monologue-markdown which will replace the default editor with a simple Markdown editor.
Seems like pretty active development also.

What ruby based forum software would you recommend for integration into an existing rails application?

What ruby based forum software would you recommend for integration into an existing rails application and allows single sign-on? I have seen many suggestions in posts for forum software that is no longer maintained (2008 and earlier).
Beast is the most current one I know of, and I'm sure it's the one you are referencing.
The rest is more of a side note, but, when I first got into rails, i asked similar questions, aka, what is the best blog, cms, forum, etc to use? As it turns out, the Rails community as a whole is interested in use cases that fit outside the plug-n-play web apps, so most people will end up rolling their own to fit their needs exactly if they find occasion to build such an app in Rails. The good news is that I think that I remember hearing that beast is like 800 lines of code, so it can't been too burdensome to either upgrade out of 2.2ish rails or just copy over the logic you need for your forum.
Thredded is very actively maintained!
Thredded is a Rails engine, so it is very easy to integrate it into an existing app.
http://github.com/radar/rboard
Rboard is really pretty awesome. :)
I always refer to Ruby Toolbox on what the rails comunity prefers.
Here's a good reference http://ruby-toolbox.com/categories/forum_systems.html
Based on the list there are two projects
Rboard - last commit 25 days ago
altered_beast - last commit 12 months ago
I agree with Jed Schneider, in the end most rails guys will roll out their own to fit the exact needs.
Forem and Discourse look promising:
https://github.com/radar/forem
https://github.com/discourse/discourse

How: Ruby on Rails to build a basic site [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm a compsci student who wants to get learn a little about web development -- I learn best by doing. I know basic html/css/php/javascript/xml, but since Ruby is one of my favourite scripting languages, I figured I'd learn Ruby on Rails.
I'd like to build a basic website for a friend's club at school that just provides information about their organization and services they offer, and have an admin panel on it that contains a very basic inventory system (item, number in inventory, cost -- that's it) in order to learn Ruby on Rails. I'll be hosting it on a computer on campus -- so I don't have to worry about hosting.
This might sound a little silly, but as someone who's never built a website themselves, I was wondering how exactly one goes about it with rails -- like, how do I make a basic layout for the main part of the site -- with things like "Home, About Us, Services, Contact, Club Executive" along the top? Do I have to make it in html and put it in the "view" section? The tutorials I've read on rails (Getting Started With Rails) actually make the basic inventory system seem easy, compared to this part, using a lot of the built in functionality of Rails and scaffolding. The Rails documentation is a tad bit confusing.
The "official" Rails book is quite good if you want to start building Rails applications. link
But actually is something like this:
Create the rails app using rails applicationname
Create the controllers. It seesm that for you one controller is actually enough, name it for example main: ruby script/generate controller main
Now you have a controller in app/controllers, called main_controller.rb. Here you can insert the actions you want this controller to respond. If you don't want the controller to do anything just show the view, then leave the method empty.
class Main < ActionPack::Controllers
def index
end
def about
end
def contact
end
(...)
end
Now you got a controller that will respond to index, about and contact.
Create the views for this controller in app/views/main/index.erb (and others, like about.erb)
You can simply use HTML if you want
Alternatively you can use a layout, that you have to define in app/views/layouts/main.rhtml In this layout use HTML, but wherewer you want to include the view, write <%= yield %>
Example:
<HTML>
<BODY>
<%= yield %>
</BODY>
</HTML>
You can include this layout in the controller by writing layout :main in the class (before the method declarations)
Now if you run ruby script/server in the root of the app you can access the pages you've created. They will be static of course, but this might get you going. You have to add models and some logic to your controllers to advance. I advice you to check the book I linked if you're interested in more, or check the alternatives of rails like merb (http://merbivore.org) which has some nice features and is usually faster, but lacks the maturity of rails.
I picked up the book "Agile Web Development with Rails", and it's excellent. It goes through building an online grocery cart.
You should read about Model-View-Controller architecture if you have not yet done so, as it is the basis for most web frameworks including Ruby on Rails.
It sounds to me like this site might not be the best way to learn Ruby on Rails.
Rails is really great for CRUD applications (applications which allow users to Create, Read, Update, and Delete records in a database). Since your site looks to be all static pages except for the "Contact Us" section (which I'm assuming is a form that sends an email with some kind of confirmation page), you're actually going to find yourself kind of fighting against "The Rails Way."
Ideally in a situation like this, you could just throw all of your static pages into the public/ directory and make a quick Rails scaffold for the "Contact Us" page.
But by doing that, you won't end up with a finished project that resembles a typical Ruby on Rails application, and in the worst case, you might find yourself having to "unlearn" or at least "relearn" a lot of the aspects of Rails programming.
I think building a CRUD application with several resources (the canonical "Rails blog in 15 minutes" is a great start. You'll learn more by practicing Rails conventions and seeing the kind of workflow and application that really allows Rails to shine.
Then when it comes time to build another mostly-static website, you'll know exactly what you'll need to do to go about it.
My 2 cents, anyway.
Start off with Mephisto. It will give a framework to achieve your goal rather fast... otherwise you may simply flounder learning the gazillion things involved in creating the rails website.
With a simple site, I'd go for a Ruby micro-framework. The three I like are: Sinatra, Ramaze or _why's 4k Camping (get the one with the bugs fixed). RoR would be overkill.
I must recommend Ramaze. If you already know Ruby, but don't know Rails yet, Ramaze is better suited to you because it is "closer to home" as far as Ramaze apps being pure(r) Ruby.
For your DB access, you get a choice of ORMs. Sequel is most popular among Ramazers, but there's also DataMapper and M4DBI.
As Alan Alavi already said: You should familiarize yourself with MVC, but that can be done simply by diving in and getting your hands dirty.

Best Solution For Authentication in Ruby on Rails [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm looking for a pre-built solution I can use in my RoR application. I'm ideally looking for something similar to the ASP.NET Forms authentication that provides email validation, sign-up controls, and allows users to reset their passwords. Oh yeah, and easily allows me to pull the user that is currently logged into the application.
I've started to look into the already written pieces, but I've found it to be really confusing. I've looked at LoginGenerator, RestfulAuthentication, SaltedLoginGenerator, but there doesn't seem to be one place that has great tutorials or provide a comparison of them. If there's a site I just haven't discovered yet, or if there is a de-facto standard that most people use, I'd appreciate the helping hand.
AuthLogic appears to be the new kid on the block and seems to be the next evolution of restful_authentication, easier to use, etc
http://github.com/binarylogic/authlogic/tree/master
Edit: now that Rails 3 is out, Devise seems to be the new, new kid on the block
https://github.com/plataformatec/devise
or I have been rolling my own authentication now with the has_secure_password built in to Rails http://railscasts.com/episodes/250-authentication-from-scratch-revised
Side note: Ruby Toolbox is a great site for finding the current best solution in various categories (based on the number of GitHub watchers):
http://ruby-toolbox.com/categories/rails_authentication.html
I would really recommend Restful Authentication. I think it's pretty much the de-facto standard.
For a really simple solution go with Clearance.
If you are looking for more options Devise is a great solution. It uses Warden which is a rack based authentication system.
There's also RestfulOpenIDAuthentication if you want OpenID support in addition to password support.
Just a note, LoginGenerator and SaltedLoginGenerator have been superseded by Restful Authentication and are unsupported on newer Rails releases -- dont waste any time on them, though they were great at the time.
I'd also like to point out an excellent tutorial/discussion on extending the core functionality of Restful Authentication, in case you're looking for something a bit more robust.
I'm really liking thoughtbot's clearance. Very simple and has a few good hooks and is testable.
AuthLogic seems to be what you want for this. It's very configurable, and although it doesn't generate the code for you, it's quite easy to use. For email validation and password recovery you probably want to use the :perishable_token column. AuthLogic takes care of it, you only need to reset it when it's used. For information on how to set up a basic app, you can take a look at Ryan Bates' Railscast on AuthLogic, and the "official" example app. Ben Johnson, the creator of AuthLogic has also written a blog post on how to RESTfully reset passwords.
Unfortunately I can't post more than one link, but the links to the railscast, the password reset blog post and the example app are all in the README (see the AuthLogic repo for the README)
Update: Now I can post more links, so I linked some more. Thank you marinatime for adding the link in the meanwhile
restful_authentication is a powerful tool which is very flexible and provides most of what you are looking for out of the box. However, a couple of caveats:
Don't think in terms of 'controls'. In Rails the Model, View and Controller are much more independent than in 'Webforms-style' ASP.NET. Work out what you want from each layer independently, write tests/specs to match and make sure each layer is doing what you expect.
Even if you are using a plugin there is no substitute for reading (at least some) of the code generated. If you have a big-picture idea of what is going on under the hood, you will find debugging and customising much easier.
The plugin restful_authentication and other plugins that extend it, answer your needs perfectly. A quick search on github.com will reveal a lot of tutorials, examples, and extensitons. Just go here:
- http://github.com/search?q=restful_authentication
There are several projects that use restful_authentication just to provide examples of a bare-bones Rails app with just the authentication parts.
http://github.com/fudgestudios/bort -- A base rails app featuring: RESTful Authentication
http://github.com/mrflip/restful_authentication_example -- Another project with a great examlpe of how to use restful_authentication
http://github.com/activefx/restful_authentication_tutorial -- Same as above, with some other plugins bundled.
http://railscasts.com/episodes/67-restful-authentication -- a great screencast explaining restful_authentication
This information should be enough to get you started finding heads and tails ... good luck.
Just updating this: Ryan Bates' Railscast #250 shows building an authentication system from scratch....
Another vote for Clearance - perhaps not as customisable or as 'in' as authlogic, but in terms of just being able to drop it in place and go, it's definitely worth having a look at.

Resources