【问题标题】:Facebox and rails not working!Facebox 和 rails 不工作!
【发布时间】:2016-07-04 14:44:16
【问题描述】:

我正在尝试将 Facebox 与 rails 一起使用,它根本不起作用。

我已将所有文件添加到正确的位置:

  • 安装 FaceboxRender gem install FaceboxRender
  • 下载jQuery
  • https://github.com/defunkt/facebox下载facebox
  • 将facebox js文件复制到/public/javascripts/
  • 将 facebox css 文件复制到 /public/styleshees/
  • 将facebox所有图片文件复制到/public/facebox/
  • 更新布局的 stylesheet_link_tagjavascript_include_tag 以添加这些 js、css 文件

我已在我的应用程序控制器中包含 FaceboxRender

我错过了什么

这是一个仅用于测试的链接:

<%= facebox_link_to 'Posts', posts_path %>

错误:

can't convert Symbol into String
Extracted source (around line #1):

1:  <li><%= facebox_link_to 'Posts', posts_path %></li>
2: 
3: 
4: <% @photos.each do |photo| %>

我尝试将 config.gem "facebox-render" 添加到我的 config/environment.rb 但我只是得到错误!

虽然我已经安装了 gem, 我运行 rake gems:install 安装时没有问题,但是当我

rake db:迁移

我收到此错误:

Missing these required gems:
  facebox-render  

You're running:
  ruby 1.8.7.174 at /opt/local/bin/ruby
  rubygems 1.3.6 at /Users/Mister/.gem/ruby/1.8, /opt/local/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems. 

任何帮助都会很棒!

谢谢

【问题讨论】:

  • 那些错误会是......?
  • gem env的结果是什么?

标签: ruby-on-rails facebox


【解决方案1】:

1.在 Gemfile 中包含 gem 'facebox-rails'
2.运行bundle install
3.粘贴到您的 application.js

jQuery(document).ready(function($) { 
    $('a[rel*=facebox]').facebox() 
})

4。在你的view 中,比如 something.html.haml(如果你使用 erb 只需添加 )只需添加

= link_to "Link name",your link, rel: "facebox"

【讨论】:

    【解决方案2】:

    问题是这一行:1:

  • 将 posts_path 更改为旧样式:

  • {:controller => 'posts', :action => 'index'} %>
  • 【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-08
      相关资源
      最近更新 更多