Tagged Questions
0
votes
0answers
35 views
Equivalent of ruby code for PHP?
Equivalent of ruby code for PHP?
PHP
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
$execResult = curl_exec($ch);
RUBY
uri = ...
2
votes
1answer
23 views
How to display an attribute of a related model when using collection_select in Rails
I Have a MTI set up with a Client inheriting from Person. I also have a Project which is in one-to-one relationship with Client model . In my view project/new.html.erb I would like to create a ...
1
vote
1answer
19 views
How can I drive a controller spec for a nested route's new method?
I have a fairly simple route setup:
resources :users, only: [:show] do
resources :account_groups
Which generates these routes:
$rake routes CONTROLLER=api/account_groups
...
0
votes
2answers
18 views
Different devise models using same email id to register
I have created two different devise models and it's working fine . But the issue i am facing now is , that both the users are able to register with the same email id . I am looking to an easy fix for ...
4
votes
1answer
44 views
Equivalent ruby code for PHP MD5 Key
I tried the equivalent ruby code for the following PHP code.
PHP code:
var $secretKey = "19535CF3D949D4EF56F8D3D4ED78C505";
$sign=md5 ($post_data.$this->secretKey );
Tried Ruby code:
...
0
votes
1answer
31 views
Routing errors when upgrading from rails 3.1 to rails 3.2 due to underscores in module namespaces
We have a rails application and we have a API namespace defined as Api::V1, Api::V1_2, Api::V1_3 etc.
In routes.rb, we have set the following
namespace :api do
["v1", "v1.2", "v1.3", ...
0
votes
0answers
19 views
Oracle and Rails throwing error undefined method `accept' for nil:NilClass
I'm currently using Rails 3.2 with the activerecord-oracle_enhanced-adapter gem. I am connecting to an already existing table in an already existing database. I have created the controller, model, and ...
0
votes
0answers
25 views
get a reference to a class to output meta information of calling class
I am debugging some callbacks in our ActiveRecord models. I'd like to have a globally available method like the following:
logger.info("at end of ITEM calling check_status")
but I'd like to have a ...
0
votes
1answer
16 views
Intersection of Search Results in Ruby
I am building a product search that is display in a Ruby on Rails application. My original model looked like this:
def candidates
@search ||= find_product.items
end
def store
.... Store ...
-4
votes
1answer
34 views
Ruby/Rails update model attribute with array items? [closed]
I am trying to populate column_name with items from @enc. Problem is #update_all updates all fields with last item in array?
Last item is ...
1
vote
1answer
21 views
alias_method chain issue in application controller
I'm using sorcery for login. In my application controller i'm overwriting sorcery logged_in? method by using alias_method chain as follows.
alias_method_chain :logged_in?, sorcery
protected:
def ...
0
votes
0answers
5 views
Connecting Rails 3.2 to existing Oracle Database
I currently have my Rails 3.2 environment connected with an already existing database, with the oracle_enhanced-adapter handling the connection. What I need to do now is take the already existing ...
0
votes
1answer
20 views
How do I use Ruby refinements inside Rails Controller/Action?
If I try outside the controller it works:
using ParamsExtension
class ApplicationController
If I try inside the controller or an action it does not work:
class ApplicationController
using ...
0
votes
1answer
25 views
curl_init and curl_setopt equivalent of ruby
What is the curl_init and curl_setopt equivalent of ruby?
$apikey='xxx';
$apisecret='xxx';
$nonce=time();
...
0
votes
0answers
6 views
Intermittent activesupport errors
So our app is experiencing intermittent errors - they happen every few minutes or so, but when you refresh the page, it goes away.
Here is the error from the logs:
ActionView::Template::Error ...
0
votes
1answer
10 views
How can change format date in a text field?
I want change format date in a textfield in my form, but show this error
undefined method `strftime' for :fecha:Symbol
This is my code
<%= f.text_field :fecha.strftime("%d/%m/%Y") %>
any ...
0
votes
1answer
25 views
Is necessary put “add_index” in a migration one to many?
For example in this migration I have a relation one to many "Category has many Subcategories". If I not put "add_index :subcategories, :category_id", it work anyway.
class CreateSubcategories < ...
0
votes
0answers
33 views
rspec error in Rails3: Formatter 'nested' unknown
My tests were running fine, then suddenly I started getting this error whenever I tried to run rspec:
/.rvm/gems/ruby-2.0.0-p451/gems/rspec-core-3.0.2/lib/rspec/core/formatters.rb:167:in ...
3
votes
1answer
35 views
Is “configuration” a reserved name?
I am creating a scaffold with name "configuration" but it doesn't work, displaying the error:
"undefined method `all' for ActiveSupport::Configurable::Configuration:Class"
I tried the same scaffold ...
0
votes
0answers
8 views
JS/jQuery does not work on assets precompile in production envoirnment
I am facing an issue on mobile devices default browser. I fixed issue somehow, and check by accessing local IP on mobile, it worked fine but when i deployed the app on live server and then i tested ...
0
votes
1answer
33 views
rails migration give me incorrect version number
I have a weird problem with rails migration, when I do a migration script by typing this command :
rails generate migration my_migration
the number of the migration will be an increment of the ...
0
votes
0answers
16 views
Selecting messages and displaying it in another
I have used Mailboxer for showing in-app messages to users . All's good and working , i display the inbox , sent and trash using accordion . My issue is , i want to display the selected message in a ...
0
votes
1answer
26 views
Which Rails app server is request being requested from
I have a rails app with 3 different app servers. If I wanted to display the server that the request was served from on the rails view ow would I do that?
More specifically my issue has to to with ...
-1
votes
2answers
127 views
Ruby on Rails Association with model
I am beginner Ruby on rails.Application have 4 model.State, Province, District and City.
Model
app/models/state.rb
Class State < ActiveRecord::Base
has_many :provinces
end
app/models/province.rb
...
0
votes
0answers
25 views
What is the equivalent ruby code for urllib2 in Python
I want to pass url, headers and query_params. The following is the python code. I want to do it with ruby. I surfed the net and know Net::HTTP is the correct way of doing this. But this method does ...
3
votes
1answer
105 views
intercepting I18n translation / what does extend Module.new { … } do?
I have a small logic, that alows I18n 'inplace translation' with AJAX, directly on the page. Therefore I want to intercept I18n.translate
My investigations brought me to this - nice and clean looking ...
0
votes
1answer
27 views
File URL in Rails
I have an action in my controller:
def download
@file = FilmFile.find(params[:film_file_id])
@file.film.downloads += 1
@file.film.save
send_file @file.real_name.path, content_type: ...
0
votes
0answers
16 views
JSON render issue - Rails3
I have my application running on the RoR stack of Ruby 1.9.3 and Rails 3.2.8, In one of my controllers, this snippet of code
if user.save
hash = { data: user.name, success: true,
...
0
votes
0answers
47 views
how to track file downloads in rails?
I have a problem when trying to count downloads and send_file in the same action
here is my code
def download
@file = FilmFile.find(params[:film_file_id])
@file.film.downloads += 1
...
0
votes
2answers
37 views
Update a new table column incrementing the value in rails 3.2
I want to order the entries in my table and they will be reordered by the user later so I don't want to use the ID. I have just added the :order column and the values are currently all nil. I know I ...
0
votes
0answers
61 views
Best way to encrypt user password via command line Ruby client to authenticate with a Rails application
Background: We currently have a Rails application that uses Devise & LDAP for authentication. Users simply provide their user & password to sign-in/login and establish a session via a ...
0
votes
1answer
39 views
How to search and display records from a table in Ruby on Rails?
I want to create a search form for the users so that they can search for one field and get the all records matching that.
I have a books model that has fields:
name:string, author_id:integer, ...
0
votes
1answer
24 views
Tell Rails application to load/use the gems in the vendor rather than the default (/usr/local/)
i have vendorized my apps gems in vendor and want my application to use those stored at /vendor but every time i start the application,it loads from /usr/local inspite having bundle install --path ...
0
votes
0answers
16 views
Using Mailbox Gem between two seperate devise models
I have implemented Mailboxer successfully for userA . For the other userB , i have mentioned acts_as_messeagable in the model . Also i have tried creating different controllers and views for the userB ...
0
votes
1answer
26 views
redirect to index if status code 500
I've added this to my show action on my controller:
redirect_to shows_path, status: 500
doesn't seem to be doing the trick.
I just want it to go to show index whenever there's a internal server ...
0
votes
1answer
40 views
refactor code to avoid N+1 query
I have my association like this
models/transcription.rb
class Transcription < ActiveRecord::Base
belongs_to :transcription_status, :class_name => "TranscriptionStatus",
:inverse_of => ...
0
votes
1answer
31 views
Line/Row separator/delimiter in exported CSV using Ruby CSV
Is it possible to change the default line separator from newline '\n' or '\r\n' to some other character, e.g '|' while importing.
I know this seems foolish. But i have multiple records in csv file ...
0
votes
1answer
31 views
Rspec for exporting to excel?
lib/export.rb
require 'writeexcel'
require "#{Rails.root}/lib/writeexcel"
class Export
include ApplicationHelper
def initialize(values)
@values_ids = values
end
def ...
0
votes
2answers
22 views
How to give different filename to ftp file while downloading in rails
I have:
1) files on ftp with names (@track.path.path) like "b573c8150fbc0dc6f5de6a9d4db79277_128.mp3" etc
2) in database each file has nice name (@track.fname) like ...
0
votes
1answer
43 views
Super Strange Ruby, or Rails, Non-Error
Given this code block:
user.products.where(id: products.map(&:id)).update_all(test_field: "")
products.each do |product|
if true
product.test_field = "Made it"
product.save!
end
...
0
votes
2answers
47 views
Connection Timed out in Installing rails
I am using Ubuntu 14.04 LTS and ruby version is: 1.9.3p484
While running the command
sudo gem install rails -v 3.2.18,
I am getting this error
WARNING: Error fetching data: Errno::ETIMEDOUT: ...
0
votes
0answers
20 views
Using Wicked gem for two seperate devise models
My application currently consists of 2 types of users , UserA and UserB . As i faced the problem of multi-step form implementation , i found wicked to be the solution . But can it be used to implement ...
0
votes
1answer
28 views
How to set default 'uuid-ossp' extension to all migration files using rails?
How to set default 'uuid-ossp' extension to all migration files?
enable_extension 'uuid-ossp'
I'm using ruby 2.1 and rails 4
PostgreSQL
Thanks,
1
vote
2answers
39 views
Why will my local variable not change as the tabs change?
I'm having trouble getting my local variables to switch between tabs. The locals are set under the h3 tag under each tab that uses the form. From there, the local is passed to the category variable so ...
-1
votes
1answer
34 views
Update one value in params
I am getting this in my params:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"wdOkjrI8no6xcooBaNithP1KtVNvwvwyJL1vcEuFTSo=", "complete"=>"not completed", "commit"=>"Save Data", ...
0
votes
0answers
28 views
Rails3 partial index with postgresql
In a migration, a partial index is defined as follows to have only column price_1 where its value is greater than zero.
add_index :products, :price_1, where: "(price_1 > '0')"
the schema ...
2
votes
1answer
52 views
Paranoid an increment! counter may not be working properly
Last week I implemented a :view_count integer column on a Job model. Today I was comparing stats between my site and Google analytics. The numbers for pageviews didn't agree (sometimes way off) and I ...
0
votes
0answers
54 views
Is this suppose to work ? rails newbie
I have worker and a lot of other models that belongs to ticket model and each ticket has many workers, since it's a huge form I opted to split it into several models and thus different views so it ...
0
votes
2answers
54 views
Ruby on Rails: Required input field CSS not showing
I have a form and I'm setting a field to be required before submitting, however nothing is showing up when I hit the Search button. What do I need to do to style the form?
<%= form_tag ...
-1
votes
1answer
24 views
Rails 3: Merit Leaderboard (HMBTM association) for venues & seasons
I am trying to understand how to pass my @venues variable into the 'merit_scores_override.rb' and use SQL to categorize based on the venues associated with that season. So when leaderboard has params ...