I have a brand new rails app and want to use the bootstrap-generators gem.
I have followed the instructions on their website, but if I now generate a scaffold I don't get the bootstrap styled inputs/buttons/etc.
screenshot
Notice that the button is the standard rails button, not the nice bootstrap button. As you can see, the main layout does have bootstrap theme working
I can see that the bootstrap template files are in the /lib/templates/erb/scaffold folder. If I now create a new scaffold it seems that these templates are ignored.
What am I missing, and why woudn't the bootstrap scaffold templates be used?
Spring was running in the background and therefore the new template files were not being loaded. Simply typing 'spring stop' fixed all my problems :)
Related
I was recently introduced to Ruby on Rails and the slim template. As I create a new app using the rails new appname command, under app/views/layouts, there are the erb files such as:application.html.erb. As expected right? Is there any way for me to create a new rails application where instead of an application.html.erb file, it's application.html.slim from the get go?
Just add the slim-rails gem to your Gemfile and then all generated view files will use .slim extension.
It hasn't been updated in 2 years but it still works fine for me on Rails 6.
You can call the following template in the existing app it should setup slim for your app.
rails app:template LOCATION='https://railsbytes.com/script/X8Bska'
There are plenty of other helpful templates which you can use to speed up the setup
https://railsbytes.com/
I'm trying to learn how to use Bootstrap with a rails application and don't understand a difference between the Bootstrap Starter Template and what I see when I load my rails app.
I copy-paste the source code of the Starter Template directly into my root view of my application. But when I run rails s, and go to localhost, the div with h1 "Bootstrap Starter Template" is displayed to the left and underneath navbar.
I've googled reasons for this, and I've seen that there's a solution to add padding to the body class.
What I don't understand:
why do I need to add the padding solution to my copy-pasted view when the same source code displays perfectly fine on the bootstrap examples page
I'm not sure if this matters, but I'm using gem bootstrap-sass version 3.3.5
I'm unfamiliar with how Bootstrap is implemented on a web app built on Ruby on Rails. I've been asked to create the front-end ,HTML/CSS for new pages. I strictly have been working with small, static sites so I don't know the way to go about this. I've seen that the CSS files only include the specific code that your page requires?
Does that mean that I will have to copy each component's Boostrap CSS to a separate CSS file for my page?
You can choose one of the following gems to get all the required components of bootstrap in your rails application:
Twitter Bootstrap Rails
Less Rails Bootstrap
Furthermore detailed info to implement it on pages can be get # http://www.gotealeaf.com/blog/integrating-rails-and-bootstrap-part-1
I used a command to make the simple_form gem work well with bootstrap. I'm pretty sure it was:
$ rails g simple_form:install --bootstrap
But I've decided I'm not going to use Bootstrap as my Rails app will be mostly used with mobile phones. I'm going to go with jQuery mobile. I make use of both jQuery Mobile and Bootstrap in my app, at present, and they seem to be clashing sometimes in the use of class names. I'm just going to use jQuery Mobile which I think is sufficient. Any thoughts or useful articles on this would be handy.
So, what would be the command for undoing the above? I know it scattered a few files around the place in my app folder and I'd like to undo it to keep it clean. Thanks.
Run the following two commands:
rails d simple_form:install --bootstrap ## Destroy the existing configurations for simple_form
rails g simple_form:install ## Generate the clean configurations for simple_form
When you initially ran the generator for simple_form with --bootstrap option, it created bootstrap compatible configurations for simple_form. The changes that have been specifically made for bootstrap are spread across multiple files. It would be hard to cherry-pick them and remove unless you know exactly what needs to be removed and what to keep for simple_form.
I am creating a custom CSS stylesheet for a Rails 3 application.
Is there a list anywhere of the CSS styles that Rails relies upon? So far I have found:
#notice
#error_explanation
.field_with_errors
Many thanks.
The css for the flash-messages you can choose yourself, as they are normally defined in application.html.erb (there is no default definition for flash-messages in rails 3).
For form-styling i would recommend using a gem like formtastic, which not only greatly simplifies making forms, but also provides a standard css file. So all needed tags are then known (and can be overwritten if needed).
If on the other hand you are looking at ways to get your complete layout started quickly, you might want to checkout web-app-theme or activo (which is even more complete).
A fresh Rails 3 app will not require any specific CSS class/id styles beyond the three you just mentioned, which is why no default stylesheet is generated until you start scaffolding.
If you run script/rails generate scaffold MyModel it will create a stylesheet called scaffold.css which the generated views will rely upon.