Rails for Zombies Lab 4 Exercise 3
def create
@zombie = Zombie.create(params[:zombie])
redirect_to @zombie
end
Rails for Zombies Level 4 Exercise 3 (WITH Rails 4 Strong Parameters)
the method zombie_params
filters the parameters correctly.
But you're not using that method when you create the Zombie
object.
Instead of doing
@zombie = Zombie.create(params[:zombie])
use the method@zombie = Zombie.create(zombie_params)
Rails for Zombies - Lab 3 › Exercise 4
The code you are looking for is:
<% if zombie.tweets.count > 1 %>
SMART ZOMBIE
<% end %>
rails for zombies lab3 excercise 3, stuck?
Your HTML-Structure is messed up:
<% zombies.each do |zombie| %>
<li>
<=% zombies.name %>
<% end%>
</li>
should be<% zombies.each do |zombie| %>
<li>
<%= zombie.name %>
</li>
<% end %>
Rails for zombies level 5 video: Why wouldn't tweets_path work?
tweets_path
won't work here because there isn't a route called 'tweets_path' in his routes.rb file. The only routes that he has (at least that we can see) is the '/all' route, which goes to the tweets controller and index action. If Greg put resources :tweets
in his routes.rb file, then tweets_path
would work. Also, if you have the code get '/all' => 'tweets#index'
(i.e. without as: 'all_tweets'
), then all_path
will work. With as: 'all_tweets'
, then only all_tweets_path
will work
Related Topics
How to Test Strong Params with Rspec
How to Make Two Thor Tasks Share Options
How to Remove Backslashes from a JSON String
How to Reverse a Linked List in Ruby
Why Can't Net::Ftp Connect to Server
Running Rails Console with Bundle Exec
What Hash Function Does Ruby Use
Time Availability Comparison, Using Ruby on Rails
What's an Example of Ruby Code That's "Too Clever"
Error Generating Source Map - Grunt and SASS Configuration
Ruby: Is It Acceptable to Put More Than One Class in a File
Rvm - Macports Won't Update Through Proxy
Static Page Routing in Sinatra (Ruby)
Foreign Key (Class_Id) Not Populating in Belongs_To Association
How Does The "#Map(&Proc)" Idiom Work When Introspecting Module Classes