Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 49 lines (40 sloc) 1.142 kb
2fc380c @elentok added model scaffold
elentok authored
1 class EntriesController < ApplicationController
2 # GET /entries
3 # GET /entries.json
4 def index
54bc505 @elentok add user to navbar
elentok authored
5 auth_hash = request.env['omniauth.auth']
6
7 @user = nil
daba0f1 @BlueHotDog fixing session
authored
8 if session[:user_id]
54bc505 @elentok add user to navbar
elentok authored
9 @user = User.find(session[:user_id])
10 end
11
2fc380c @elentok added model scaffold
elentok authored
12 @entries = Entry.all
13
14 respond_to do |format|
15 format.html # index.html.erb
16 format.json { render json: @entries }
17 end
18 end
19
20 # GET /entries/1
21 # GET /entries/1.json
22 def show
23 @entry = Entry.find(params[:id])
24
25 respond_to do |format|
26 format.html # show.html.erb
27 format.json { render json: @entry }
28 end
29 end
30
31 # POST /entries
32 # POST /entries.json
33 def create
38c9c79 @BlueHotDog adding add entry
authored
34 entry_params = params[:entry]
254a642 @psychocandy adding user_id to the entries model
psychocandy authored
35 @entry = Entry.new({url: entry_params[:url], user_id: session[:user_id]})
2fc380c @elentok added model scaffold
elentok authored
36
37 respond_to do |format|
38 if @entry.save
39 format.html { redirect_to @entry, notice: 'Entry was successfully created.' }
40 format.json { render json: @entry, status: :created, location: @entry }
41 else
42 format.html { render action: "new" }
43 format.json { render json: @entry.errors, status: :unprocessable_entity }
44 end
45 end
46 end
47
48 end
Something went wrong with that request. Please try again.