What is the architecture diff in execute command rails new projectname and rails new projectname --api?

Please any idea and any solution

rails new -h

will show you the options available to the new command.

According to the official rails website, there are three main differences between a rails web application and a rails api:

1 - The api app is configured to start with a more limited set of middlewares than normal. Specifically, it will not include any middleware primarily useful for browser applications (like cookies support) by default

2 - In the api app, ApplicationController inherits from ActionController::API instead of ActionController::Base. As with middlewares, this will leave out any Action Controller modules that provide functionalities primarily used by browser applications.

3 - The api app is configures the generators to skip generating views, helpers and assets when you generate a new resource.

You can always convert your rails app from either one of these to the other one. To do so, follow the steps in the reference I mentioned above.

Anyway, if you want to see the exact differences just generate 2 applications, one with the flag and another one without it, and then just use one for the many tools available to compare files and directories

2 Likes

Thnak you pj.martorell