Twitter Bootstrap in Rails - ruby-on-rails

I generated views using this command
rails g bootstrap:themed Todo
it generated several views for my model.
I am using git and reverted the project to its former branch without the boostrap.
Now, I am trying to regenerate the views but it always returns this
identical app/views/manifests/index.html.erb
How do I force the bootstap generator to regenerate the views for my project?
TIA

I was able to work it out by moving my project into another directory, preferably into a different folder.

Related

Overriding the default views in RailsAdmin

I am using Ruby on Rails 4.2.1 with RailsAdmin. The gem works excellent, but I have the requirement that the layout of the admin panel and the forms must look different than what is generated by default. For example, the navigation should be horizontal top, the forms should order the fields in two columns.
So far I haven't find a way to copy the views locally and modify them (like in Devise for example). I have tried to replicate the views manually in the respective path under my views folder by copying the original views, but I got problems with the helper methods that are part of RailsAdmin not being accessible from my views.
I dug deeper and found that there is a task copy_views, it was referred to in questions for the older versions of the gem, but if I try to use it now rake rails_admin:copy_views, it is not available anymore.
Am I doing something wrong, or is there another way to do this?
You can create folders in your app
app/views/rails_admin/main for https://github.com/sferik/rails_admin/tree/master/app/views/rails_admin/main
app/views/layouts/rails_admin/ for
https://github.com/sferik/rails_admin/tree/master/app/views/layouts/rails_admin
Put modified files there. It can get a little messy and you will need to update the files if the gem changes.

Override Mailboxer Views in Rails 4

I'm using Mailboxer into my app but I'm having some problems with the generated views (with rails g mailboxer:views). Seems to be the internal Mailboxer mailer are using some "hidden" templates and any changes over the existing views are not reflected on the sent emails.
Can anyone help me with that? One known alternative could be to program my own mailer class, but I think that it's a bit more of work to achieve the same thing.
Thanks.
It may be a bug. I am experiencing the same thing:
https://github.com/mailboxer/mailboxer/issues/324
The origin of the problem is that "rails g mailboxer:views" copies the gem templates folders into "app/views" folder and the engine searches inside app/views/mailboxer.
The solution consists in moving the two generated (message_mailer and notification_mailer) folders into a subfolder "app/views/mailboxer".

Deleting empty asset files in Rails

When using scaffolding in Rails, you end up with placeholder .css/.scss and .js/.coffee files under the assets directories. Unless I am adding something to one they will stay empty.
I would assume the assets pipeline would ignore the empty files when compiling, but is there any reason I wouldn't just delete them all?
rails generate scaffold is just a helper. It simply generated everything that could possibly be useful to you.
Sure you can delete all unneeded files. You could also delete a model or controller after it has been created if you don't need it anymore.

How do I use a dummy application to test a gem (preferably with Cucumber)?

I'm making a gem that will add some custom responders to an application's controllers. To test this, I'm going to need a dummy application sitting inside of a test directory that I can load and somehow generate views from.
I'd prefer to use Cucumber to test this gem, because that is what I'm most comfortable with having used it in the past.
How do I generate an application inside of my test directory like this? I will need at least a controller and a model, but views aren't necessary (the responder is only for JSON). Can I just generate a new Rails app within /features/support/dummy? How would I run the dummy application from within my test suite?
At first, do not generate anything within features/support/. That's the place for global hooks.
Your problem sounds not hard if I understood correctly. Here is my proposed steps.
Create a demo directory in project root. New demo app will be under it.
Create a ruby module/class under features/support/, with methods to generate a demo app and delete it. The demo app will be simply some directories like app/contorllers for test purpose. Making a whole new Rails app sounds overkill.
Create a tag for the Scenario which need generate app. Add Before and After hook for this tag to add and remove app for this Scenario, by calling the module/class in #2

Change Rails Scaffold Naming Scheme

I'm a happy user of RoR but have one complaint. When I do script/generate scaffold it automatically generates all my files and places them in their proper folders. However, all the different scaffolds I've created name their view files the same.
I have a bunch of index.html.erb view files and when I have them open in my text editor, it's almost impossible to tell what controller they're related to.
I'd like to change the default naming scheme of the scaffold command to name the individual files to contain their view folder name. So, instead of index.html.erb, use index.home.html.
Is there a way to do this, or am I stuck? What solutions to the multiple files with the same name problem have you Rails developers discovered?
Thanks!
You're going to be fighting the Rails' conventions by going down that path and Rails works best when you work with it rather than against it. A core part of the philosophy of Rails is that there are a set of conventions that once learned make it easy to find your way around any Rails application.
Instead of trying to redefine how Rails works, I would recommend taking advantage of the features offered by your text editor or IDE for quickly navigating to the correct view template. For example, the Rails bundle within TextMate on the Mac lets you quickly open the view file associated with a particular model and there's a plugin for Vim that provides an equivalent feature.

Resources