| Start |
|---|
| Create a modular app 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.
Let’s run Great, 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 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 listWe are going to scaffold a model named That’s it, now when we run migrations from the parent application, the migrations in the Todo engine will be loaded too.
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 Yay, now we can destroy tasks! Syntax
|
Read Article
https://develop.horje.com/learn/1434/reference