Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove json support from the generated scaffold #188

Open
dira opened this issue Jun 19, 2014 · 0 comments
Open

Remove json support from the generated scaffold #188

dira opened this issue Jun 19, 2014 · 0 comments

Comments

@dira
Copy link
Contributor

dira commented Jun 19, 2014

The generated coontroller is very verbose, and not so easy on the eyes.

By removing json support we could have code that is simpler, more intuitive, and easier to understand:

# POST /ideas
def create
  @idea = Idea.new(idea_params)

  if @idea.save
    redirect_to @idea, notice: 'Idea was successfully created.'
  else
    render :new
  end
end

# similar for `update` and `delete`

instead of:

# POST /ideas
# POST /ideas.json
def create
  @idea = Idea.new(idea_params)

  respond_to do |format|
    if @idea.save
      format.html { redirect_to @idea, notice: 'Idea was successfully created.' }
      format.json { render :show, status: :created, location: @idea }
    else
      format.html { render :new }
      format.json { render json: @idea.errors, status: :unprocessable_entity }
    end
  end
end

The only downside is that, in order to do that, we need to change
rails new railsgirls

into

rails new railsgirls --skip-bundle
open Gemfile and comment out gem 'jbuilder' bundle install`,

which adds 'weird things' in the beginning. Which is why I'm asking for feedback instead of PR'ing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant