One of the things I love about Grails is the ability to generate controllers and scaffolded views.
I've decided to build a new project without Grails, on Java using spring-boot. I was wondering if there was some sort of tool that will do the equivalent of the Grails 'generate-all' command that is something that will generate the controllers and views from my model so I can get a head start with my development.
I'd preferably want to create my views with thymeleaf, although I know that might be asking a bit much.
Related
I'm cleaning up an old Rails application, and I managed to do quite a cleanup on the routes files.
I'm trying to figure out a way if it is possible to map the routes file with non-existent controllers and methods so I can further clean up the code.
Is this even possible?
For my specific problem this is a Rails 3 site, but the question I guess applies to all versions of Rails.
I have installed CKeditor for my Rails app and while doing the Formatting, the Formatted code does not display in the screen, instead, HTML is rendered, like this
<h2><strong>In this project</strong> you’ll create a simple blog system and learn the basics of Ruby on Rails including: Models, Views, and Controllers (MVC) Data Structures & Relationships Routing Migrations Views with forms, partials, and helpers RESTful design Using Rails plugins/gems The project will be developed in five iterations. I0: Up and Running Part of the reason Ruby on Rails became popular quickly is that it takes a lot of the hard work off your hands, and that’s especially true in starting up a project. Rails practices the idea of "sensible defaults" and will, with one command, create a working application ready for your customization. Setting the Stage First we need to make sure everything is set up and installed. See the Environment Setup page for instructions on setting up and verifying your Ruby, Rails, and add-ons. This tutorial was created with Rails 4.0.0, and may need slight adaptations for other versions of Rails. Let us know if you find something strange! From the command line, switch to the folder that will store your projects. For instance, I use /Users/jcasimir/projects/. Within that folder, run the rails command:</h2>
Use the html_safe method
So, something like:
puts my_variable.html_safe
Lots more info here: http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/
I want to create another project inside exisiting rails app. My reasoning is that:
They have some common models which I would be able to link to from the inner app,
They operate on the same database
They will have one version control system (no additional configuration and moving required)
Apart from why I want to do that I just want to know why rails prevents you from doing that? As of my testing, no conflicts were exposed.
You should be using Rails Engines for this. Here's a Railscasts episode about it. http://railscasts.com/episodes/149-rails-engines
I want to create a sms payment engine and reuse it in several applications. It would be best to be able to just copy/paste one directory, maybe configure some minor stuff and just have it working (with views, controllers, etc.).
What's the best way to do this? Of course I'm not asking about this sms thing but about the way to create an isolated piece of application. It's something like a helper application inside of the major application.
There a three ways to build Rails extensions : plain-old ruby code, Railties and Engines.
Railties and Engines allow you to interact with the Rails framework during the initialization using hooks and therefore extend Rails. Actually, every major Rails component (ActiveRecord, ActionPack, etc.) is a Railtie.
The main difference between a railtie and a Rails engine is that an engine can define its own configuration, models, controllers and views. In a way, an engine is a Rails application you can deploy in another one. In your case, I guess a Rails Engine would be the right choice.
Whatever the option you use, you will have to build a gem to distribute your extension and share it across projects.
Here is a gist explaining both the Railtie and Engine concepts
A guide to starting your own rails engine.
Enginex, a command line tool which creates a Rails 3 Engine
I guess the best way to reuse your code is putting them to a gem, then install that gem.
I think the best way to extract reusable part of your application is to create a RubyGem. You can find a tutorial about creating RubyGems here. And there is a Jeweler, a very nice tool to create RubyGems. More about Jeweler, you can find here
Maven Archetypes are handy ways to get a project up and going in no time flat. Rails is kinda like an archetype in and of itself. However, I'm curious to know if there are any Rails equivalents for Maven Archetypes.
For example, I want to create an Archetype with full authentication already built in via Authlogic. With Maven Archetypes I would need to build a project with it already ready to go, create my archetype and start working back parameterizing things that should be parameterized. Then anyone can make a Rails project with Authlogic set up by filling out a few questions during the archetype generate command and boom! Fully functional Rails app with Authlogic built in.
Is there a Rails Equivalent? Are Generators expected to do this? Is this just not Rails-y?
I think that rails app templates are the most similar thing to Maven Archetypes. http://railscasts.com/episodes/148-app-templates-in-rails-2-3 is a good starting point to get an opinion about them.
Perhaps you are looking for Modules and Mixins?
I'm not sure but rails casts might have something else to add.