Is it possible to modify rails scaffold command to generate forms using simple_form gem input fields?, instead of having the developer to edit each form and convert it to use simple_form data fields?
PS: I did Google and search Stack Overflow before posting, all I found was how to modify existing scaffold, which is not what I want.
Thank you
You can override the templates used for generated views by putting templates here:
lib/templates/erb/scaffold
take a look at:
Rails 3.1 - changing default scaffold views and template
Related
Anyone suggest me some plugin or gem in rails 4 which is Generate dynamic form just like google form
Actually, I want create form according with field type
I'm really thankful of you
https://docs.google.com/forms/d/1nS_mrAMhig-qRBZKAg-M9aTGca1dzNppTciSuFAUtKQ/edit
I'm building a dynamic web app that each paragraph could be editable with one click. Just wondering if anyone has any recommendation's how I could go about that without using a CMS.
Give a try to ckeditor :
gem 'ckeditor', github: 'galetahub/ckeditor'
This type of implementation sounds like more of a JavaScript question. You'll need to look into the rails API and may need to disable turbolinks.
You can even use the rails generator for scaffolding to build out your models and controllers. I'd recommend nesting two models.
rails generate scaffold Article title:string author:string
rails generate scaffold Paragraph content:text article:references
At this point you will need to wire up your javascript editor to your update method in the controller.
I currently found simple_form gem for rails application. I currently join the rails project and added this to existing project.
After installation it creates form for new migrations with simple_form. I want to migrate all existing forms to use simple_form.
How can I accomplish existing non simple_form layout forms to use simple_form layout.
Is there any way to generate forms using console or script to make simple_form layout?
Unfortunately, I don't believe there is a generator that can translate all your other forms in to the simple_form layout for you.
If the forms you have now currently work, I would say there is no need to change them. The point of the gem is to make it easier to create new forms. Use simple_form going forward and leave the ones that work. In the future if any form breaks, rewrite it in the simple_form DSL.
i want to generate a complex scaffold and then remove the gems
is there a way to freeze the code that rails_admin or activescaffold generates so i can edit it myself ? (similar to how rails scaffold does it)
is there another gem that generates a more complex scaffold?
In active scaffold to alter a scaffold's views you use overrides.
This depends on what version of Rails you're running. If >2.1, you can specify gems explicitly in environment.rb using config.gem, and then run rake gems:unpack to freeze those gems into the vendor/gems folder. For >=3.0 use the Builder tool to freeze the gem.
If <= 2.1, then you could do the above step manually -- copy all of the ActiveScaffold gem code into a folder in vendor/plugins, and remove the gem itself. See earlier plugin-based versions of ActiveScaffold for guidance.
You can also do this only as needed. To customize views, create an app/views/active_scaffold_overrides folder, and copy any ActiveScaffold partials to customize there. They will automatically be used across your app -- no need to duplicate them into each view. To customize controller actions, create a controller named ActiveScaffold, and then have all other scaffold controllers inherit from this new ActiveScaffoldController. Now you have somewhere to override the actions themselves, and you can override helpers in the generated ActiveScaffoldHelper file too.
I use the great form builder plugin 'formastic' to build a form. It is rather ugly though. How can I set style to it? I find little information through the documentation. Note: I use the newest 1.2.3. with ruby 1.8.7 and rails 3.0.3.
If you used the formtastic generator (rails generate formtastic:install), you have two CSS files in the public/stylesheets subdirectory, called formtastic.css and formtastic_changes.css. Look into the first one to see how formtastic sets the default styles, and then override these in formtastic_changes.css.