# Getting started
First, let’s generate a new Ruby on Rails application:
The next step is to generate an engine!
We will also create an ‘engines’ folder to store the engines (even if we just have one!).
Engines, just like gems, come with a gemspec file. Let’s put some real values to avoid warnings.
Now we need to add the Todo engine to the parent application Gemfile
Let’s run bundle install. You should see the following in the list of gems:
Our Todo engine is loaded correctly! Before we start coding, we have one last thing to do: mount the Todo engine.
We can do that in the routes.rb file in the parent app.
We are mounting it at / but we could also make it accessible at /todo. Since we have only one module, / is fine.
Now you can fire up your server and check it in your browser. You should see the default Rails view because we didn’t define any controllers/views yet. Let’s do that now!
Building the Todo list
We are going to scaffold a model named Task inside the Todo module but to correctly migrate the database from the parent application, we need to add a small initializer to the engine.rb file.
That’s it, now when we run migrations from the parent application, the migrations in the Todo engine will be loaded too.
Let’s create the Task model. The scaffold command needs to be run from the engine folder.
Run the migrations from the parent folder:
Now, we just need to define the root route inside the Todo engine:
You can play with it, create tasks, delete them… Oh wait, the delete is not working! Why?! Well, it seems JQuery is not loaded, so let’s add it to the application.js file inside the engine!
This ruby on rails tutorial page provides you the following key areas such as ruby , rail , ruby on rails , rail forum , ruby on rails tutorial , ruby tutorial , rails guides , rails tutorial , learn ruby , rails form_for , ruby rails , ruby class , what is ruby on rails , rails installer , ruby online , learn ruby on rails , ruby on rails jobs , rails find_by , install rails , easyrail , rubyonrails , link_to rails , ruby on rails developer , learn ruby the hard way , railscasts , ruby on rails examples , ruby on rails vs php , rails 4 , rails activerecord , rails generate , ruby and rails , ruby on rails download , install ruby on rails , ruby net http , what is rails , ruby app , ruby vs ruby on rails , ruby on rails windows , rails for zombies , ruby on rails book , ruby on rails development , ruby on rails ide , ruby on rails tutorial pdf
Related Searches to create a modular app in ruby on rails