Sha256: 311399e3c0f389cae5079a7f728eb2e45f3525dbcc038f92c4b41333bdb28dc7
Contents?: true
Size: 1.76 KB
Versions: 25
Compression:
Stored size: 1.76 KB
Contents
class PlanetsController < ApplicationController before_action :set_planet, only: [:show, :edit, :update, :destroy] # GET /planets # GET /planets.json def index @planets = Planet.all end # GET /planets/1 # GET /planets/1.json def show end # GET /planets/new def new @planet = Planet.new end # GET /planets/1/edit def edit end # POST /planets # POST /planets.json def create @planet = Planet.new(planet_params) respond_to do |format| if @planet.save format.html { redirect_to @planet, notice: 'Planet was successfully created.' } format.json { render action: 'show', status: :created, location: @planet } else format.html { render action: 'new' } format.json { render json: @planet.errors, status: :unprocessable_entity } end end end # PATCH/PUT /planets/1 # PATCH/PUT /planets/1.json def update respond_to do |format| if @planet.update(planet_params) format.html { redirect_to @planet, notice: 'Planet was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @planet.errors, status: :unprocessable_entity } end end end # DELETE /planets/1 # DELETE /planets/1.json def destroy @planet.destroy respond_to do |format| format.html { redirect_to planets_url } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_planet @planet = Planet.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def planet_params params.require(:planet).permit(:name) end end
Version data entries
25 entries across 7 versions & 1 rubygems