• #10 楼 @icesky 还是不对吖...5555

  • #7 楼 @icesky 都不对吖...5555

  • #6 楼 @linjunhalida 可 post 没有 delete 方法呀.

  • #4 楼 @linjunhalida config/route.rb:::::::::

    resources :posts do 
      resources :comments
    end
    
  • #2 楼 @blacktulip

    <% @post.comments.each do |comment| %> 
     <p><%= comment.user -%>:<%= comment.body %>      </p> 
        <% if session[:user_name] == "rails" -%>
         <div class="edit_link"> 
        <%= link_to '删除', [comment.post, comment], :confirm => 'Are you sure?', 
                            :method => :delete,
                            :action => "show",
                            :controller => "post" -%> 
        </div>
        <% end -%> 
    <% end %>
    
  • #9 楼 @Ryan 点击 blog 超链接只有提示::: undefined methodposts' for nil:NilClass` Extracted source (around line #17):

    14:     &nbsp;<%= nav_link '帮助', 'site', 'help' -%>&nbsp;
    15:     </span>
    16:     <span style="float:right">
    17:     <% if session[:user_id] -%>
    18:     &nbsp;<%= nav_link '个人中心','user','index' -%>&nbsp;|
    19:     &nbsp;<%= link_to 'blog', blog_posts_path(@blog.posts) -%>&nbsp;| 
    20:     &nbsp;<%= nav_link '登出','user','logout' -%>&nbsp;
    

    我也分不清....

  • #7 楼 @Ryan 下面是 user_controller.rb

    def index
      @title="User Hub"
      @user = User.find(session[:user_id])
      @spec = @user.spec ||=Spec.new
      @blog = @user.blog ||=Blog.new
       @blog.posts.build
    end
    

    应该怎么做

  • #4 楼 @Ryan <%= link_to 'blog', blog_posts_path(@blog.posts) -%> 错误: 'undefined method `posts' for nil:NilClass'

  • #4 楼 @Ryan 好我再来试试。

  • #1 楼 @Ryan 其实有好几个错误。我都不知道哪个是哪个了!

  • #1 楼 @Ryan 是的!

  • #23 楼 @ShiningRay no,redhat.but there's no package libmysqlclient-dev

  • #19 楼 @ShiningRay it worked!!! Really really appretiate for your help! but here's another problem.I created a rails project,installed mysql,updated the /config/database.yml to support mysql instead of sqlite3. when "rails server",it appears as the following:::: Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine. Run bundle install to install missing gems.

    but type "bundle install" still fails:: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /home/liuzhou/.rvm/rubies/ruby-2.0.0-p195/bin/ruby extconf.rb

    checking for mysql_ssl_set()... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

    what should i do????please help!

  • #19 楼 @ShiningRay Thanks a lot!! I'm trying!!

  • It's hard to finish the project...

  • #15 楼 @ShiningRay could you please tell me how to solve the problem @#14lou

  • I "rails testweb",then "cd testweb",then "ruby script/server"..and something goes wrong,here's the following description: => Booting WEBrick => Rails 2.3.14 application starting on http://0.0.0.0:3000 /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21:in add_frozen_gem_path': undefined methodsource_index' for Gem:Module (NoMethodError) from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:298:in add_gem_load_paths' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:132:inprocess' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:in send' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:inrun' from /home/liuzhou/testweb/config/environment.rb:9 from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:in gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:inrequire' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:innew_constants_in' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in require' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/commands/server.rb:84 from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:ingem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:in `require' from script/server:3

    thank you for you help...

  • I "rails testweb",then "cd testweb",then "ruby script/server"..and something goes wrong,here's the following description: => Booting WEBrick => Rails 2.3.14 application starting on http://0.0.0.0:3000 /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21:in add_frozen_gem_path': undefined methodsource_index' for Gem:Module (NoMethodError) from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:298:in add_gem_load_paths' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:132:inprocess' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:in send' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:inrun' from /home/liuzhou/testweb/config/environment.rb:9 from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:in gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:inrequire' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:innew_constants_in' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in require' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/commands/server.rb:84 from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:ingem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:in `require' from script/server:3

    thank you for you help...

  • I "rails testweb",then "cd testweb",then "ruby script/server"..and something goes wrong,here's the following description: => Booting WEBrick => Rails 2.3.14 application starting on http://0.0.0.0:3000 /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21:in add_frozen_gem_path': undefined methodsource_index' for Gem:Module (NoMethodError) from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:298:in add_gem_load_paths' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:132:inprocess' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:in send' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:inrun' from /home/liuzhou/testweb/config/environment.rb:9 from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:in gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:inrequire' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:innew_constants_in' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in require' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/commands/server.rb:84 from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:ingem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:in `require' from script/server:3

    thank you for you help...

  • I "rails testweb",then "cd testweb",then "ruby script/server"..and something goes wrong,here's the following description: => Booting WEBrick => Rails 2.3.14 application starting on http://0.0.0.0:3000 /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21:in add_frozen_gem_path': undefined methodsource_index' for Gem:Module (NoMethodError) from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:298:in add_gem_load_paths' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:132:inprocess' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:in send' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb:113:inrun' from /home/liuzhou/testweb/config/environment.rb:9 from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:in gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:inrequire' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in require' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:innew_constants_in' from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in require' from /usr/lib64/ruby/gems/1.8/gems/rails-2.3.14/lib/commands/server.rb:84 from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:ingem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:45:in `require' from script/server:3

    thank you for you help...