RailsCasts Pro episodes are now free!

Learn more or hide this

Semyon Perepelitsa's Profile

GitHub User: semaperepelitsa

Comments by Semyon Perepelitsa

Avatar

I find it better to put the global scope directly into the controller:

def scope_current_tenant &block
  Topic.with_scope Topic.where(tenant_id: current_tenant.id), &block
end

That way everything outside it will work the same way as before.

Avatar

Did you see turbolinks? Looks like you are developing the same thing.

Avatar

Anyone had luck with using jQuery File Upload UI in Rails?

Avatar

DELETE /products/1/delete looks rather confusing, I think it is better to use POST verb in this case: POST /products/1/delete. Also, these are perfectly valid RESTful routes, there is nothing wrong with them.

I would also suggest to extend your routing DSL explicitly instead of patching Rails internal classes so that the modification is obvious for you and others. This will also avoid troubles with external engines that will expect default behavior.

ruby
# lib/delete_resource_route.rb
module DeleteResourceRoute
  def resources(*args, &block)
    super(*args) do
      yield if block_given?
      member do
        get :delete
        delete :delete, action: :destroy
      end
    end
  end
end

# config/routes.rb
require 'delete_resource_route'

Example::Application.routes.draw do
  extend DeleteResourceRoute
  resources :categories
  resources :products
  root to: 'products#index'
end
Avatar

I have used ActiveModel::Serializers::JSON module to make a serializer/presenter class and I like this approach better than Jbuilder.

Avatar

There is XML Builder that comes bundled with Rails ("builder" gem)

Avatar

You can skip require "rubygems" since Ruby 1.9

Avatar

This is why we are saving them into a separate variable

javascript
states = $('#person_state_id').html()
Avatar

But when you get out of it in production you'd better have a well-tested billing system :-)

Avatar

Since jQuery 1.6 you should use prop() method to set boolean attributes: $('input[type=submit]').prop('disabled', true)

Avatar

There is no PayPal yet in my work, but it was interesting to watch this episode. One thing that bothers me though is that you skip testing part which is crucial in billing and payments. I know, the episode would be two times longer if you covered this as well but it was very scary to see you just quickly testing the stuff in a browser.

Avatar
ruby
root to: "public#welcome"
constraints subdomain: /.+/ do
  root to: "sites/public#welcome"
end

http://guides.rubyonrails.org/routing.html#specifying-constraints