How to customize css form in rails

The team rails generate devise:viewssuccessfully created folders under\app\views\users

I want to customize development forms, but not sure if css will be hosted in application.cssor if I need to create one separately user.css.scss. Googled a little and checked the git doc for this, but no one points to CSS handling in development.

Tell me the correct way to handle it.

+5
source share
3 answers

Devise will use your default layout. That way, the CSS that you use in yours views/layouts/application.html.erbwill be used in your generated development views.

, views/layouts/devise.html.erb, CSS. - Rails.

, , , . views/layouts/reservations.html.erb ReservationsController

Devise::RegistrationsController, views/layouts/devise views/layouts/devise/registrations.html.erb

+10

, , , application.css, , :

registrations.css.scss

Rails.application.config.assets.precompile assets.rb.

, app/assets/stylesheets/, .

, - :

4.1

<%= stylesheet_link_tag controller_name, media: 'all' if Rails.application.assets.find_asset("#{controller_name}.css") %>

Rails 4.2 +

<%= stylesheet_link_tag controller_name, media: 'all' if asset_present?("#{controller_name}.css") %>

# ...meanwhile, somewhere in the helpers...

def asset_present?(name)
  # Rails 4.1 had Rails.application.assets filled out in all environments.
  # Rails 4.2 has it filled only when config.assets.compile == true which is only
  # in development by default.
  if Rails.application.assets.present?
    Rails.application.assets.find_asset(name)
  else
    Rails.application.assets_manifest.files.values.map { |v| v['logical_path'] }.include?(name)
  end
end
+4

Run this line to create a device view.

rails generate devise:views

and do whatever you want with the page style.

to read more Click here

+2
source

All Articles