Last active
August 29, 2015 14:06
-
-
Save Choongkyu/60bcca98dcacf069cd08 to your computer and use it in GitHub Desktop.
blog attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>BlogRailsguides</title> | |
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> | |
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> | |
<%= csrf_meta_tags %> | |
</head> | |
<body> | |
<header> | |
<% if user_signed_in? %> | |
You are signed in as <%= current_user.email %>. Not you? <%= link_to 'Log out',destroy_user_session_path %> | |
<% else %> | |
You are not logged in. What say you? <%= link_to 'Sign up', new_user_registration_path %> or <%= link_to 'Sign in', new_user_session_path %> | |
<% end %> | |
</header> | |
<%= yield %> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EntriesController < ApplicationController | |
def new | |
end | |
def edit | |
@entry = Entry.find(params[:id]) | |
end | |
def create | |
@entry = Entry.new(entry_params) | |
if @entry.save | |
redirect_to @entry | |
else | |
render 'new' | |
end | |
end | |
def index | |
@entries = Entry.all | |
end | |
def show | |
@entry = Entry.find(params[:id]) | |
end | |
def new | |
@entry = Entry.new | |
end | |
def entry_params | |
params.require(:entry).permit(:title,:text) | |
end | |
def destroy | |
@entry = Entry.find(params[:id]) | |
@entry.delete | |
redirect_to :action => 'index' | |
end | |
def update | |
@entry = Entry.find(params[:id]) | |
if @entry.update(entry_params) | |
redirect_to @entry | |
else | |
render 'edit' | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if 1==1 %> | |
<% redirect_to controller:entry, :action => :index %> | |
<% end %> | |
<h1>Welcome#home</h1> | |
<p>Find me in app/views/welcome/home.html.erb</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Showing C:/Users/Quilty-dell/rails_projects/blog-railsGuides/app/views/welcome/home.html.erb where line #2 raised: | |
undefined method `redirect_to' for #<#<Class:0x5257740>:0x39a4a00> | |
Extracted source (around line #2): | |
1 | |
2 | |
3 | |
4 | |
5 | |
<% if user_signed_in? %> | |
<% redirect_to :controller => 'entry', :action => 'index' %> | |
<% end %> | |
<h1>Welcome#home</h1> | |
Rails.root: C:/Users/Quilty-dell/rails_projects/blog-railsGuides | |
Application Trace | Framework Trace | Full Trace | |
app/views/welcome/home.html.erb:2:in `_app_views_welcome_home_html_erb__426885810_30432108' | |
Request | |
Parameters: | |
None | |
Toggle session dump | |
Toggle env dump | |
Response | |
Headers: | |
None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment