Tang Rufus

Joined

190 Experience
0 Lessons Completed
0 Questions Solved

Activity

For those who want similar behaviour on before_action :authenticate_user!

  def authenticate_user!(opts = {})
unless opts || user_signed_in? || devise_controller? || !redirectable?
store_location_for(:user, request.fullpath)
end
super(opts)
end

def redirectable?
request.get? && !request.xhr? && is_navigational_format?
end

Great tutorial!
Just released my first gem [viewport_units_buggyfill](https://github.com/TangRufu...

Not sure if it is good to name my gem with underscores, or should i rename it with dashes?

Posted in PDF Receipts Discussion

Is it possible to render the pdf without controller? maybe sending out via emails, or saving to s3

Posted in How to make a good Sidekiq job?

From the Sidekiq wiki, a Sidekiq job should be idempotent and transactional. How should we implement this?

For example, I am sending notification emails via Mandrill. How can I ensure that the email would not be sent multiple times?

Besides, is it good to wrap the jobs in ActiveRecord::Base.transaction when creating/updating/deleting database records?

Thanks!

Posted in Mobile App with Devise Facebook OmniAuth

My Rails 4 app is using Devise and Facebook OmniAuth. The web app is working perfectly. Now I want to make a iOS app to consume my rails app's API.

Instead of telling iOS users to type in their auth_token from devise-token_authenticatable gem, how can iOS app users login my Rails app after Facebook authentication?

Thanks!

Posted in When to use scoped models?

In Refactoring CSV Uploads with ActiveModel::Model Download , you make a scoped class User::Import.
When should we use scoped class like this?

And, how does it different from rails generate model user/import?

Thanks!

Posted in How to create a dynamic form for Contest/Giveaway app

ActionForm might suits your needs.
As the Rails team is taking over it, it would be great if @excid3 make a screencast about it.