Omnis On Rails

RSS

capucine, projet web light

Voici un lien vers le site officiel de cette gem qui facilite l’intégration de SASS+Compass+CoffeeScript dans vos projets web indépendamment de Rails.

Bonjour gem: Mercredi c'est Active record

bonjourgem:

gem install activerecord

La base de données tranquille

J’ai récemment eu besoin d’interagir avec une base de données sans me soucier de son format. J’ai donc pensé à Active record.

Active record fait partie des gems que vous connaissez si vous utilisez Ruby on Rails. Dans un script Ruby…

Ruby On Raile Guides Offline

kuroir:

Want to have a offline version of Ruby on Rails Guides? Just do:

cd rails-directory/railties/guides
ruby rails_guides.rb

Where rails-directory is where the gem is located (you can clone it from github). The output directory contains the html files of the guide.

fernando blat: Nginx + upload module + Rails + Carrierwave

blat:

I have just set up nginx file uploading for Toldo, so now, our Passenger processes are not blocked anymore meanwhile the users upload their, each time bigger, photos.

It has been really easy following this post: Uploading multiple files with nginx upload module and upload progress bar, so…

giant robots smashing into other giant robots: Danger, Danger: High Voltage! Use Rails 3.1 for Static Sites

thoughtbot:

I’m a big fan of Jekyll, but boy do I love SCSS and CoffeeScript. I recently set out to create a static site using Rails 3.1, to take advantage of the lovely Sprockets integration. There are alternatives (like Middleman, and Octopress) but I wanted to use Rails itself instead.

Our…

Tableless Models in Rails 3.0

rhinon:

While working on a “bug management” rails project I encountered a unique situation where I wanted to leverage the power of rails without actually backing the data with a table in the database.  (Specifically, we manage bugs with a horrible, horrible internal tool which I access through command line)

Anyways, it appears while this involved hacking in Rails 2.x, in 3.0 this is a lot more graceful with the abstraction of ActiveModel from ActiveRecord!

Rails Best Practices solutions

bohdanzhuravel:

http://www.codeschool.com/courses/rails-best-practices

Level 1

Challenge 1/6 : Named Scope

app/models/following.rb:
class Following < ActiveRecord::Base
  scope :recent, order('created_at desc').limit(10)
  belongs_to :user
end
app/controllers/user_controller.rb:
class UserController < ApplicationController
  def index
    @followings = current_user.followings.recent
  end
end

Challenge 2/6 : Scope with Lambda

app/models/following.rb:
class Following < ActiveRecord::Base
  scope :recent, lambda { where('created_at > ?', 2.days.ago) }
end
app/controllers/user_controller.rb:
class UserController < ApplicationController
  def index
    @followings = current_user.followings.recent
  end
end

Challenge 3/6 : Default Scope

app/models/following.rb:
class Following < ActiveRecord::Base
  default_scope order('created_at DESC')
end
app/controllers/user_controller.rb:
class UserController < ApplicationController
  def index
    @followings = current_user.followings
  end
end

Challenge 4/6 : Model Creation Scope

class FollowingsController < ApplicationController
  def create
    current_user.followings.create
    redirect_to root_url, :notice => 'Successfully followed!'
  end
end

Challenge 5/6 : Skip a Filter

class ProfilesController < ApplicationController
  skip_before_filter :require_login, only: :show
  def show
    @user = User.find(params[:id])
  end
end

Challenge 6/6 : Fat Model / Skinny Controller

app/models/user.rb:
class User < ActiveRecord::Base
  has_many :followings

  def follow(user)
    unless followings.where(:followed_user_id => user.id).present?
      followings.create(:followed_user => user)
    else
      false
    end
  end
end
app/controllers/users_controller.rb:
class UsersController < ApplicationController
  def follow
    @user = User.find(params[:id])

    if current_user.follow(@user)
      redirect_to root_url
    else
      redirect_to @user
    end
  end
end

Read More

PookeBook Great Free eBook Download Sıte: Ruby on Rails Web Mashup Projects: A step-by-step tutorial to building web mashups

pookebook:

ruby-on-rails-web-mashup-projects-a-step-by-step-tutorial-to-building-web-mashups
Use Ruby and Ruby on Rails to develop seven functional mashup jobs subsequent stage-by-step guidelines. This ebook is for Ruby on Rails developers who want to increase the functions of their internet site by consuming remote exterior information and services. Basic knowledge of Ruby on…

Tad Thorley: Rails With SpineJS and Google Maps

tadthorley:

I wanted to create a simple project that used ruby on rails, spinejs, and google maps together. I came up with the following features:

  • Dragging a marker icon from outside of a map onto a map creates a marker on the map and in the database
  • Dragging a marker from one position to another updates…

Tad Thorley: For SpineJS With Rails Use spine-rails

tadthorley:

I’ve been learning how to use spinejs with rails. When I’m learning I like to forgo code generators as much as possible and write the necessary code myself. I’ve done that with the past few projects I’ve posted here. However, for most of my future projects I’m going to use the spine-rails gem….