ruby-on-rails-3

Downgrading a Rails 3 App to Rails 2

纵然是瞬间 提交于 2019-12-25 05:18:12
问题 I've run into a problem today. I've spent the past couple of months building a fairly intensive Rails 3 App that uses all the latest versions of every gem I need. I've just been informed that I can't use anything new. I'll be adding my project in with a bunch of others which use older versions of everything. We can't upgrade the existing, we can only downgrade mine. With that said, I need to downgrade pretty much everything I've done. Here's a list of what I'm using currently (via gem list ):

How can pass parameter with httparty gem after authentication

五迷三道 提交于 2019-12-25 05:12:02
问题 I am working for importing odesk API into my local project. for that i used omniauth-odesk gem for authentication and httparty gem for call http request for access odesk information. in my Gemfile.rb gem 'omniauth-odesk' gem 'httparty' in odesk_controller.rb class OdeskController < ApplicationController include HTTParty def user_details @odesk_user = env["omniauth.auth"] end def search_job @response = HTTParty.get "http://www.odesk.com/api/profiles/v2/search/jobs.json", :headers=>{

How can pass parameter with httparty gem after authentication

纵饮孤独 提交于 2019-12-25 05:11:13
问题 I am working for importing odesk API into my local project. for that i used omniauth-odesk gem for authentication and httparty gem for call http request for access odesk information. in my Gemfile.rb gem 'omniauth-odesk' gem 'httparty' in odesk_controller.rb class OdeskController < ApplicationController include HTTParty def user_details @odesk_user = env["omniauth.auth"] end def search_job @response = HTTParty.get "http://www.odesk.com/api/profiles/v2/search/jobs.json", :headers=>{

rufus-scheduler runs scheduler multiple times due to unicorn workers

我只是一个虾纸丫 提交于 2019-12-25 05:06:25
问题 I had setup scheduler in my rails3 projects's /configs/initializers/schedule.rb and it working fine, But it works 2 times and I think it is due to unicorn workers execute schedule at the same time, so it create in my database two records each time. I checked my logic and its ok and enter single record in my local machine. I checked following but not getting idea how to stop multiple unicorn workers to execute scheduler? https://github.com/jmettraux/rufus-scheduler/#advanced-lock-schemes Any

Rails URL case sensitive

梦想的初衷 提交于 2019-12-25 05:06:07
问题 I want my login URL to be case insensitive in my Rails application. e.g if the user types in 'User_Login' it should redirect to 'user_login'. I m using rails 3.1. Any help would be appreciated. Thanks 回答1: Had the same problem a long time ago. Have a look at my solution here: http://gehling.dk/2010/02/how-to-make-rails-routing-case-insensitive/ / Carsten 来源: https://stackoverflow.com/questions/11827233/rails-url-case-sensitive

Ruby rails - jquery auto complete - combine multiple values for a list item

荒凉一梦 提交于 2019-12-25 05:05:28
问题 How do I parse values of an rails instance variable to create an auto complete list of jQuery? So my '/user/search' return an instance variable with multiple values per item. I wanna combine them and present as a list item. def search if (params[:term] =~ /[a-zA-Z]/) @result = User.FindLdap("sAMAccountName", params[:term]) else @result = User.FindLdap("idnumber", params[:term]) end respond_to do |format| format.html { render :partial => 'text_for_autocomplete'} format.js end end I am using

newbie : getting mutual likes and only if they are mutual with active record?

岁酱吖の 提交于 2019-12-25 04:59:31
问题 What would be a good way to get mutual likes ? where 2 users like each other ( as in a friendlist) and get only those users who have a mutual match? user_id | likes_id 1 2 2 1 Only get results where both of the users likes each other ( friendship ) I have tried some join's but can't really get it to work, is there a building AR feature to get the above results? 回答1: To add to jexact's answer this is one way you can do this using AR: Like.joins('join likes l on likes.user_id=l.likes_id and l

How to render collection with template in rails3?

给你一囗甜甜゛ 提交于 2019-12-25 04:59:17
问题 If there is a _post.html.erb in app/views/posts/, I can input <%= render @posts %> in app/views/posts/index.html.erb , but if the _post.html.erb file in app/views/users/posts/, how to write? I tried <%= render @posts, :template => 'users/posts/post' %> , but it does not work. 回答1: <%= render :partial => 'users/posts/post', :collection => @posts %> 来源: https://stackoverflow.com/questions/10916851/how-to-render-collection-with-template-in-rails3

How to prevent polluting a rails object when using form_for and .new?

我们两清 提交于 2019-12-25 04:59:09
问题 I have a model: class Activity < ActiveRecord::Base has_many :activity_states end I want to render options for new activity states and render existing activity states. However when I use this form_for: <%= form_for activity.activity_states.new, :remote => true do |f| %> <%= f.hidden_field :state_type, :value => activity_state_type %> <%= f.hidden_field :activity_id %> <%= f.submit submit_label, :disable_with => 'sending...' %> <% end %> for creating new temporary activity_state models to use

Bundle install error with “omniauth-oauth2”

三世轮回 提交于 2019-12-25 04:56:08
问题 Running bundle install I get the following error (full trace: http://pastebin.com/Vp4nHc2p): Bundler could not find compatible versions for gem "omniauth-oauth2": In Gemfile: omniauth-facebook (~> 1.2.0) ruby depends on omniauth-oauth2 (~> 1.0.0) ruby omniauth-github (~> 1.0.1) ruby depends on omniauth-oauth2 (1.1.1) To see my Gemfile: http://pastebin.com/vMcHDHa8 Any idea how to solve it? 回答1: Hi you probably need to install omniauth facebook and github versions which accept the same version