Comments (5)
Your post is undefined. Do you have @post = Post.find(params[:id]) inside the show action of the Posts controller?
from nku.
This is my code for posts_controller.rb:
class PostsController < ApplicationController
def new
end
def create
@post = Post.new(post_params)
@post.save
redirect_to @post
end
private
def post_params
params.require(:post).permit(:title, :text)
end
def show
@post = Post.find(params[:id])
end
end
Could the error possibly be in routes.rb? Do I need another get statement?
from nku.
The issue might be that you put the show action under post_params. I'm pretty sure the private keyword applies to every method defined under it. Try moving show up above the private and see what happens.
from nku.
It works! Thanks for the help, I've been having a lot of trouble with this.
from nku.
Well, now you know not to put new actions in under the private. It's kind of weird that it would get that far before hitting an error though. You'd think it would have trouble finding the action in the first place if private is a problem.
from nku.
Related Issues (20)
- ActiveRecord question HOT 2
- How can an administrator sign up? HOT 1
- Logout not being properly referenced HOT 1
- CSS / LESS not classes not being applied
- Adding upload action? HOT 3
- Creating an administrator HOT 3
- Question about to assignments ago, querying for assignments
- SASS Error HOT 5
- Rollback some commits HOT 5
- Question about STIs or polymorphic associations HOT 10
- Site won't collapse on mobile HOT 2
- I'm thinking about using devise HOT 4
- Who wants an invite to prelang? HOT 16
- Ruby Brigade tomorrow is anyone going?
- How do to safely use github? HOT 8
- Blank Pages HOT 5
- Can't Use Partial Dates HOT 4
- has_many :through => HOT 2
- validation errors HOT 4
- ActiveRecord::PendingMigrationError HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nku.