How can I ban/block specific user account with Devise on Rails3.1?

Up vote 0 down vote favorite share g+ share fb share tw.

I actually checked some previous posts about this topic. But it didn't work on mine somehow. What I did was I.

I added varchar field called 'banned' into my Users table(MySQL) Then I manually input "true" on specific record to make sure if it works. II. After signed in with devise, it automatically goes to sample.com/todos So I added some lines to /app/controller/todos_controller.

Rb then it became just like this. Though when I try to login, it doesn't take me to root path. Can anyone help?

Class TodosController "You are banned from this site. " end end ... and it goes on end and This is my routes. Rb Sample::Application.routes.

Draw do root :to => "welcome#index" devise_for :users, :controllers => { :registrations => "registrations" } get 'todos', :to => 'todos#index', :as => :user_root resources :todos devise_for :users do get 'logout' => 'devise/sessions#destroy' end end @jimworm I did took? Off and tried but it didn'nt work. @nathanvda the value of "banned" is "0" as default.

Because I added t. Boolean :banned, :default => false into migration file. Even if banned is "0(as default)" it gives this error back..... You have a nil object when you didn't expect it!

You might have expected an instance of Array. The error occurred while evaluating nil. Each ruby-on-rails devise link|improve this question edited Oct 2 '11 at 9:08 asked Oct 2 '11 at 5:05MKK234.

Off your current_user. Banned? , or put def banned?

;banned;end in User. – jimworm Oct 2 '11 at 5:31 Normally @Jimworm, if you define a boolean field in your db, rails is smart enough to immediately translate that for you to banned?. Mind you: the type must be correct for it to work.

– nathanvda Oct 2 '11 at 7:03 Could you verify inside rails console what the value of banned? Is for that specific user? – nathanvda Oct 2 '11 at 7:07 Oops missed that it was a varchar.

In Ruby, everything is true except for false and nil. I'm not sure why you made it varchar so I'll leave it at that. – jimworm Oct 2 '11 at 12:09 Thanks guys!

It worked perfectly after I took "protected" part off. – MKK Oct 2 '11 at 15:14.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions