concept class in category rails

appears as: classes, classes, class, The class, class
Rails 4 in Action: Revised Edition of Rails 3 in Action

This is an excerpt from Manning's book Rails 4 in Action: Revised Edition of Rails 3 in Action.

On the right side of the Welcome Aboard page are four links to more documentation for Rails and Ruby. The first link takes you to the official Rails Guides page, which will give you great guidance that complements the information in this book. The second link takes you to the Rails API, where you can look up the documentation for classes and methods in Ruby. The final two links take you to documentation about Ruby itself.

If you click the About Your Application’s Environment link, you’ll find your Ruby, RubyGems, Ruby on Rails, and Rack versions and other environmental data. One of the things to note here is that the output for Environment is “development.” Rails provides three environments for running your application: development, test, and production. How your application functions can depend on the environment in which it’s running. For example, in the development environment, classes aren’t cached, so if you make a change to a class when running an application in development mode, you don’t need to restart the server. The same change in the production environment would require a restart.

Listing 6.18. The new submit button on the sign-in page
<div class="form-actions"> <%= f.button :submit, "Sign in", class: "btn btn-primary" %> </div>

You defined that your comment’s association to a user is called author, but the class for your author isn’t Author, it’s User. You can fix this by specifying the class_name option on the author association in the Comment model. Open up app/models/comment.rb and add the right class_name option:

Rails 3 in Action

This is an excerpt from Manning's book Rails 3 in Action.

The core features of Rails are a conglomerate of many different parts called Railties (when said aloud it rhymes with “bowties”), such as Active Record, Active Support, Action Mailer, and Action Pack.[5] These different Railties provide a wide range of methods and classes that help you develop your applications. They prevent you from performing boring, repetitive tasks—such as coding how your application hooks into your database—and let you get right down to writing valuable code for your business.

class User < ActiveRecord::Base
  extend OmniauthCallbacks

Here you don’t need to tell Rails that the class of this association is Forem::Topic, Rails will figure that out itself. In the Forem::Topic model, you need to set up the other end of this association and accept nested attributes for it:

The class << self syntax is known as a metaclass. The code inside of it defines additional functionality on the class it is contained within. The attr_accessor method defines what’s known as an attribute accessor. This consists of a setter (user_class=) and a getter (user_class), which would usually be accessible on instances of this class. Due to how you’ve defined it, it will now be available on the class rather than the instances. These three lines are the equivalent of this: