[Rails] Re: is_a? returns false, though I think it should return true

2014-09-06 Thread Iazel
I think the cleanest solution is to use two function, one that use Fixnum and another for the Card. Obviously, the latter will internally use the first: def fn(a, b, n) # do stuff end def fc(a, b, c) fn(a, b, g(c)) end However, if you still don't like this, you can just check if the last p

[Rails] Understanding Rails internals

2014-09-06 Thread Iazel
Hello all, Is there any good resource where to start to understand how the various internal component of rails are glued together? Maybe a book that dissect this massive framework? Debugging it is never so simple, due to a lot of "magic" (aka meta programming) involved. Thanks :) -- You recei

[Rails] Re: create object after before_filter :authenticate_user!

2013-02-19 Thread Iazel
The first solution that comes in my mind: class PostsController < ApplicationController before_filter :authenticate_user!, only: [:create, :update, :destroy] def authenticate_user! session[:post] = params[:post] unless user_signed_in? super end ... end ... and then you check if se

[Rails] Custom Generators ignored

2013-02-19 Thread Iazel
I want to add a spec for _form template, and then created a generators the inherit from Rspec::Generators::ScaffoldGenerator. What I have: # lib/generators/rspec_modded/scaffold/scaffold_generator.rb require 'generators/rspec/scaffold/scaffold_generator.rb' module RspecModded module Generators