RoR: Devise Customize - ruby-on-rails

I'm trying to follow this tutorial about adding a username field to Devise: http://asciicasts.com/episodes/210-customizing-devise
However, when I edit the view files new.html.erb I don't see any changes take place when I refresh the signup/login page...
What would be causing this?

Did you do:
rails g devise:views
or
rails g devise:views MyModel
When using only only model, you need to use the former version to generate the correct views. Or rename your app/views/my_models to app/views/devise

Related

How to change the name given with devise ?

I'm currently working on my personal website.
By adding devise gems to my code, I'va made a mistake.
I've written :
rails generate devise MODEL
and I want :
rails generate devise User
I know I could just start over, but I want to know first if it is possible to change this and if it is, how could I do that ?
Many thanks,
Raphaƫl.
Remove the table:
rake db:rollback VERSION=versionNumberOfMigration
Remove the configuration:
rails destroy devise:install
Remove your User model:
rails destroy devise MODEL
Check the references to devise in your routes.rb, controllers and views.
Also check for the following code snippets in your project:
devise_for (routes.rb)
before_action :authenticate_MODEL! (controllers)
MODEL_signed_in? (controllers, views) current_MODEL
MODEL_session (controllers, views)
Have you tried
rails destroy devise MODEL

How to create separate DataBase with different tables for each client in rails

I want to create different database for each client when client signup using devise in rails application. But I don't know how to create and manage with parent database in my application. Please suggest me best solution.
I think You need to use devise_group
You need to create an extra model User
rails g devise User
rails g devise FirstUser
rails g devise SecondUser
rails g devise ThirdUser
and so on.......
Now you need to define it in your Application Controller
devise_group :everyone, contains: [:first_user, :second_user, :third_user]
but I prefer, what I have already said in my above comment.

render the correct view after rails g devise:views user

I'm trying to use devise, but after I ran rails g devise:views user it seems rails is still loading views from views/devise/... and not the correct views/users/...how to set it the right way?
Have you made sure to add this setting to your config/initializers/devise.rb file?
config.scoped_views = true

Wrapping with application.html - rails

I am really new to rails and working to customize a project. I generated a new scaffold, called it New_Scaffold. When the New_Scaffold's index.html.erb is displayed, the wrapper of the application.html.erb (where the yield method is called) is not displayed.
I thought it was automatic in rails, is it not ? How can I display the application.html.erb to wrap the New_Scaffold's index.html ?
The scaffold command generates a bunch of things for a model and controller for you automatically.
If you want to try Rails out try to create a new project like this:
rails new blog
cd blog
rails generate scaffold Post title body:text
rake db:migrate
rails server
This will create a basic project with one model, Post, that will have a generic setup with views and a controller that responds to all the RESTful actions.
the application.html.erb file can be found under views/layouts

Prefix for the rails generators

Is there a way to generate a scaffold with the admin folder prefix..For example I want one Admin folder and a few controllers for that admin folder. I want to do a scaffold for each controller in the admin folder and i wanted to know if there was something like
script/generate scaffold admin:something somefield:string
The scaffold generator can take a namespaced argument:
# Rails 3
rails g scaffold Admin::Something somefield:string
# Rails 2
script/generate scaffold Admin::Something somefield:string
Note, that if you'd like to leave model unprefixed, you have to edit some of generated files by hand to implement it. That is why I created rails-admin-scaffold gem and wrote detailed article about custom admin area scaffolding. If that's already not relevant for you, maybe it'll help someone else.

Resources