我无法弄清楚为什么我会收到这个错误,这究竟是什么意思.
表单中的第一个参数不能包含nil或为空(第3行)
<%= form_for @post do |f| %> //Error here
<p>
<%= f.label :title, 'Title' %><br/>
<%= f.text_field :title %><br/>
</p>
<p>
<%= f.label :content, 'Content'%><br/>
<%= f.text_area :content %><br/>
</p>
<p>
<%= f.submit "Add a New Post" %>
</p>
<% end %>
Run Code Online (Sandbox Code Playgroud)
控制器:
class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
def new
@post = Post.new
end
def create
@post = post.new(params[:post])
if @post.save
redirect_to posts_path, :notice => "Your post …Run Code Online (Sandbox Code Playgroud) 不要安装这个宝石,我得到这个回应.
greg@greg-VirtualBox:~$ gem install tweetstream
Building native extensions. This could take a while...
ERROR: Error installing tweetstream:
ERROR: Failed to build gem native extension.
/home/greg/.rvm/rubies/ruby-1.9.3-p362/bin/ruby extconf.rb
checking for main() in -lssl... yes
checking for main() in -lcrypto... yes
checking for openssl/ssl.h... yes
checking for openssl/err.h... yes
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... yes
checking for writev() in sys/uio.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... yes
checking for rb_time_new()... yes …Run Code Online (Sandbox Code Playgroud)