blob: 6fe26b1ec4a7ed2e011e1201c8cbf499140ce153 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
class SnippetsController < ApplicationController
before_action :set_snippet, only: [:show]
# GET /1234
def show
end
# GET /
def new
@snippet = Snippet.new
end
# POST /create
def create
@snippet = Snippet.new(snippet_params)
if @snippet.save
redirect_to @snippet, notice: "Snippet was successfully created."
else
render :new
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_snippet
@snippet = Snippet.find(params[:id])
end
# Only allow a trusted parameter "white list" through.
def snippet_params
params.require(:snippet).permit(:title, :code, :language)
end
end
|