Tag: ruby on rails 3

使用Bundler和Capistrano进行部署时出现问题

我正在使用Ruby on Rails 3.1.0和Capistrano gem。 正如Bundler官方文档中的“使用Capistrano自动部署”部分所述,我在deploy.rb文件的顶部添加了deploy.rb require ‘bundler/capistrano’ 。 现在,当我运行cap deploy:migrations命令(部署并运行挂起的迁移)时,我收到以下错误: … * executing “cd //releases/20111026132212 && bundle install –gemfile //releases/20111026132212/Gemfile –path //shared/bundle –deployment –quiet –without development test” servers: [“”] [] executing command ** [out :: ] Some gems seem to be missing from your vendor/cache directory. ** [out :: ] Could not find libv8-3.3.10.2 […]

Rails 3.2.13,500开发错误,没有日志

我在迁移rails 2.x时遇到了问题 – > 3.2.13在某些时候,在修复了一些问题后,我Completed 500 Internal Server Error in 76ms而没有任何回溯。 development.rb config.consider_all_requests_local = true config.action_controller.perform_caching = false 为什么没有追溯以及如何解决这个问题?

更改网页中的URL

当我从一个标签移动到同一页面中的另一个标签时,我怎么能更改URL地址? 我想在routes.rb或控制器中更改代码? routes.rb中: Rails.application.routes.draw do resources :dashboard, only: [:index] resources :profile do collection do patch ‘update_profile’ patch ‘change_password’ end end devise_for :users, controllers: { omniauth_callbacks: ‘users/omniauth_callbacks’ } root ‘dashboard#index’ end 我当前的url是localhost:3000/profile ,现在当我选择update_profile选项卡时,我需要url为localhost:3000/profile/update_profile而不呈现新页面 控制器代码: class ProfileController < ApplicationController before_action :set_user, only: %i[index update_profile] def index @address = if @user.address @user.address else Address.new end end def update_profile […]

Ruby on Rails Instagram Gem like和评论计数不正常

我试图循环浏览Instagram返回的数据并在网页上显示信息。 我可以从字面上得到每个字段的工作除了类似或评论计数。 出于某种原因,它总是返回所有字段的相同数字(2),即使我查看返回的JSON,计数明显不同。 其他一切都正常应用。 更具体地说,我使用Ruby on Rails Instagram Gem,使用tag_recent_media(用户)方法获取数据。 def index result = [] next_id = nil while result.length params[:page], :per_page => 30) end 在我的html.erb中: instagram.images.standard_resolution.url //gives me image url correctly instagram.caption.text //gives me caption text correctly instagram.user.username //gives me the username correctly instagram.likes.count //always gives me 2! instagram.comments.count //always gives me 2! 任何人都知道可能会发生什么?

如何使用Ruby on Rails在初始化程序中调用app Model

我是Ruby on Rails的新手,我使用的是Ruby 2.1.0和Rails 4.0.2 我的查询是: – 我想在初始化器中调用Model 。 我的Model文件是setting.rb和Model name Setting 。 它的位置是app / model目录。 我想在初始化文件paypal.rb中调用Setting Model 。 paypal.rb位置是config / initializers / paypal.rb 。 请帮助如何在Ruby on Rails中调用初始化器中的Model 。

Rails 3:比较唯一代码

保证代码唯一的最佳方法是什么? 代码是XXX-XXXXX,其中X只是一个数字。 除了在数据库表中搜索代码之外,还有什么方法可以使流程更快更干净? 问候。

可排序的表列在MongoDB中不起作用

我正在使用rails castvideohttp://railscasts.com/episodes/240-search-sort-paginate-with-ajax 。 它适用于Mysql数据库。 我想在Mongodb中实现这个。 我的application_helper.rb文件是这样的 def sortable(column, title = nil) title ||= column.titleize css_class = column == sort_column ? “current #{sort_direction}” : nil direction = column == sort_column && sort_direction == “asc” ? “desc” : “asc” link_to title, params.merge(:sort => column, :direction => direction, :page => nil), {:class => css_class} end 我的products_controller.rb文件是这样的 helper_method :sort_column, […]

WIN x64上的ruby-debug-base19-0.11.26.gem

关于我的系统的信息: ruby -v – > ruby​​ 1.9.3p125(2012-02-16)[i386-mingw32] gem -v – > 1.8.24 当我跑步的时候 bundle install 输出: Fetching source index for http://rubygems.org/ Could not find ruby-debug-base19-0.11.26 in any of the sources 防火墙关闭 我下载了这个文件:ruby-debug-base19-0.11.26.gem 但是当我跑: gem install ruby-debug-base19-0.11.26.gem 输出: Temporarily enhancing PATH to include DevKit… Building native extensions. This could take a while… ERROR: Error installing ruby-debug-base19-0.11.26.gem: […]

will_paginate和.sort =>

我最近安装了will_paginate gem并且它工作得很好,但我希望它可以使用我目前的设置。 现在我在同一页面上显示所有Feed(或post),但是在点击该页面的人数之后排序: controller.rb @t = Time.now @h1 = @t – 1.hour @feeds = Feed.find(:all, :order => “created_at DESC”).sort { |p1, p2| p2.impressionist_count(:filter=>:all, :start_date=>@h1) p1.impressionist_count(:filter=>:all, :start_date=>@h1)} 现在……我测试了paginate gem,如果我在控制器中执行此操作,它可以正常工作: controller.rb @feeds = Feed.paginate(:per_page => 10, :page => params[:page], :order => “created_at DESC”) 所以我认为1 + 1 = 2并尝试将两者结合起来: controller.rb @feeds = Feed.paginate(:per_page => 10, :page=>params[:page], :order => […]

在Heroku / Ruby on Rails上找不到PNG

在Heroku上部署后未加载PNG文件! 我正在Heroku上部署一个项目,所有资产都运行得很好,包括图像(jpgs,jpegs和gifs),但PNG文件没有加载! 一般页面显示: GET damainname.com/assets/namespace/my_image-867450b295e2051d381123c16c51548e.png 404 (Not Found) 其他图像文件扩展名(JPG,JPEG和GIF)正常加载。 我在用: Heroku雪松(使用和不使用资产进行测试:在本地进行预编译) ruby 1.9.3p448(2013-06-27修订版41675)[i686-linux] Rails 3.2.11 production.rb: config.action_dispatch.x_sendfile_header = ‘X-Accel-Redirect’ config.serve_static_assets = true config.assets.compress = true config.assets.compile = false config.assets.digest = true application.rb中: config.assets.precompile += [‘application.css’, ‘application.js’, ‘admin.css’, ‘admin.js’] config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif] config.assets.initialize_on_precompile = false