小编Gre*_*reg的帖子

Form_for"表单中的第一个参数不能包含nil或为空"错误

我无法弄清楚为什么我会收到这个错误,这究竟是什么意思.

表单中的第一个参数不能包含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)

ruby ruby-on-rails

9
推荐指数
1
解决办法
3万
查看次数

宝石安装错误

不要安装这个宝石,我得到这个回应.

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)

ruby linux gem tweetstream

2
推荐指数
2
解决办法
6733
查看次数

标签 统计

ruby ×2

gem ×1

linux ×1

ruby-on-rails ×1

tweetstream ×1