Questions tagged [ruby-on-rails-3.2]
Ruby on Rails version 3.2.0 released at January 20, 2012. Use this tag for issues related to development in Ruby on Rails version 3.2.0.
6,985
questions
0
votes
2
answers
109
views
Update record in before_destroy and prevent its destruction
I am using Rails 3.2, Ruby 1.9.3.
I need to prevent a record from being destroyed and update it in the before_destroy callback.
Given two classes with the following associations
class Course:
...
0
votes
0
answers
39
views
Authlogic timeout and single_access_token don't work together
I am using authlogic gem for the authentication and recently we implemented feature for logout_on_timeout.
So we have placed the below code:
class UserSession < Authlogic::Session::Base
...
0
votes
1
answer
173
views
Ruby on Rails: pass query parameters hash with key but nil value
In Ruby on Rails, my current url has a query parameter of ?hello. Since the request.query_parameters hash will be {:hello=>nil}, how do I pass this with link_to? Rails seems to drop any query ...
0
votes
1
answer
31
views
Access value from multidimensional Hash rails
I have to access the id and other important information of each operator.
The structure of given data is:
{:items=>
[{:id=>"868f136b-ec4e-4794-a3a9-a70d4b83ab38",
:clientId=>&...
0
votes
2
answers
716
views
Mysql2 error in starting rails server in mac m1
I have installed mysql2 in mac m1 using the below command
gem uninstall mysql2
gem install mysql2 -v '0.3.21' -- --srcdir=/usr/local/Cellar/mysql/8.0.28_1/bin/include --with-mysql-include=/usr/local/...
0
votes
1
answer
775
views
bundle update --conservative devise does not update only "devise" gem
I recently tried to update devise to the latest version specified in the gemfile without affecting its dependencies.
gemfile.lock:
devise (3.5.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
...
1
vote
1
answer
387
views
minitest/capybara error - NameError: undefined local variable or method 'page'
I'm in the process of updating the hosting for a Rails 3.2 LTS project, taking them from ruby 2.3.3 to 2.7.2.
As part of this I've updated a few gems, specifically updating
minitest from 5.11.3 to 5....
1
vote
1
answer
131
views
Pundit gem error class overriding my custom error class in ruby
my application has custom error classes defined lib/error/*
example
#lib/error/custom_error.rb
module Error
class CustomError < StandardError
attr_accessor :error, :status, :message
...
0
votes
0
answers
17
views
Rails 4 AR .select includes pk field in result even if result is grouped (as opposed to Rails 3.2)
I'm migrating my app from Rails 3.2 to 4.0, and I'm finding a number of broken tests because Rails 4 includes the PK field (usually 'id') in the result set when using something like:
Invoice.where(...
0
votes
0
answers
82
views
uninitialize constant user (work with dto)
I'm learning rails using Devise for authentication purpose and make a User by Rails generate Devise user it creates a user model for me & every thing is works fine But when i put my file (user.rb)...
0
votes
0
answers
38
views
Problem deleting server side cookies in Controller
For an application, I need to remove two server-side generated cookies if the User has selected to not allow cookies. I can detect the cookies, get the consent settings, and everything just fine. ...
1
vote
1
answer
209
views
heroku push of Rails 3.2 app suddenly fails with "Could not detect rake tasks" (no other errors)
I changed nothing in the configuration (no new gems or version changes); just one line of code, but I am now unable to push to heroku. Something must have changed at heroku?
It is Rails 3.2.22.5; ...
0
votes
0
answers
179
views
RAILS 3.2.2.1 > rails assets:precompile LoadError: cannot load such file -- net/ssh/config
rails version 3.2
ruby version 2.0.0 -p451
I'm executing:
rails assets:precompile --trace
Getting the below error.
rake aborted!
LoadError: cannot load such file -- net/ssh/config
/home/...
0
votes
2
answers
181
views
Rails find_by new column
I am new to rails ,
I have added a new column “control_id” in a table users and same is added in model file under
attr_accessible :control_id
But when I use find_by_control_id(1) . I am getting ...
0
votes
0
answers
49
views
Stack level too deep on upgrading rails 3.1.10 to 3.2.0
I am getting the following errors after upgrading my rails application from 3.1.10 to 3.2.0.
rails console is opening fine. And, I am able to execute code in console. However, When I run rails server ...
0
votes
1
answer
239
views
Possible to delete all Rails session info for all users
I am working on a legacy Rails 3.2 app and would like to log everybody out and have their _app_session be reset with the secure flag set to true. It seems like either changing our session_store ...
0
votes
0
answers
51
views
Exposing assets in development and production in Rails 3.2
I have a legacy Rails 3.2 app and if I have a JavaScript file at:
app/assets/javascripts/jt.js
I'm able to access it at
https://dev-platform.domain.com/assets/jt
We are using the asset pipeline ...
0
votes
1
answer
811
views
Ruby Benign vale for nil DateTime
When comparing DateTimes, all objects being compared must be the same type. However, I have a data set that has nil dates. I want to treat these dates as older (or perhaps newer) than any other date. ...
0
votes
1
answer
366
views
How do I give a Ruby script executed via Rails console write permissions on Digital Ocean?
I am deploying my Rails app to Digital Ocean.
I need to run a custom ruby script via the Rails console (or even on a job queue) and in some cases I want it to create a file and store it within my ...
1
vote
0
answers
106
views
calling send_file with filepath, file is getting deleted and send_data throwing "No such file or directory @ rb_sysopen"
I am trying to download xls file using
send_file file_path, :content_type => "application/vnd.ms-excel", :filename => File.basename(file_path)
But getting error as "No such file or ...
0
votes
1
answer
41
views
Can any one help to encode the rails code.I want to share my code in binary executable form?
I want to share my rails code with my client in encoded form so he can not able to read the code.Is it possible in rails
1
vote
1
answer
123
views
Rails 3.2 - Unable to load modules of initializers files
Environment
Ruby [1.9.3p547]
Rails [3.2.22.5]
Devise [3.0.4]
When i run any rails or rake command for this application it is giving me below error
/config/initializers/devise.rb:3:in <top (...
-1
votes
2
answers
588
views
Writing a matrix to a text file
So i have done how to read a matrix from a text file where the first line defines the elements, however my question is how would i do the opposite that would write to the text file. I would like it to ...
0
votes
1
answer
39
views
Listing Articles with date attribute before/after the current date
I have an admin page on my site that usually lists all appointments that users have scheduled when I use @appointments.each. I'm trying to figure out how I can list all appointments with the date ...
0
votes
1
answer
624
views
how to save a blob file using carrierwave in rails
So i have a requirement where i record a video and save it in the database, the recording of the video is working fine, only thing is it generates a blob file, then i use js to send the blob file to ...
-1
votes
2
answers
414
views
Check if an array of objects include any object from an array
I have an array of objects called posts and I have a comment in c1 as an array of comments by user Bob. Relationship between a post and comment is, a Post has_many Comments.
c1 = Comment.where(user: "...
6
votes
3
answers
1k
views
Why don't my locale settings in number_to_currency work?
Per the Rails 3.2 API Docs, to use different locales for number_to_currency, I need to do the following:
<%= number_to_currency(1234567890.506, :locale => :fr) %>
I was expecting the ...
0
votes
1
answer
667
views
How to get flow lines through the decision box in this flow chart?
I create a flow chart in HTML and CSS, where I use the decision box from which two decisions have to be made. One is coming below but the sideline flow which again redirects to the first box in the ...
0
votes
2
answers
141
views
How to remove a script from a existing migration file rails
I pulled new changes from git, in this new changes there is a migration file,
def change
add_column :users, :activated_at, :datetime
User.all.each do |user|
user.update(activated_at: user....
0
votes
1
answer
176
views
Rails CanCanCan resource abilities based on department
I have two user types Admin and Normal User
I have the following departments
Front Office (eg., id is 1)
Back Office (eg., id is 2)
Admin (eg., id is 3)
I have a model named Entry which takes ...
0
votes
1
answer
462
views
Rails: EOF Error when creating/updating a record
I recently stumbled upon a problem with my rails application.
I am using ruby 2.1.0 with Rails 3.2.7 (I know) and recently, when I create/update ANY record of ANY model, I get the EOFError - bad ...
0
votes
1
answer
72
views
How to move all values above or below an insertion up one or down one in a hash
This is for a drag and drop, I have the front end working correctly and it sends data correctly to my rails backend.
I am attempting to sort a hash based on the index position that is incoming as ...
2
votes
4
answers
267
views
How do I elegantly check for presence of both the object and associated objects?
I have an instance variable @tally_property, and if there are photos on that object I would like to cycle through the photos and show them.
So my code snippet looks like this:
<% if @...
0
votes
2
answers
82
views
Assigning role is not inserting to its corresponding model
I am implementing Assigning roles to a user. I have implemented this using has many through association. the requirement says there can be any number of roles to a particular user. have created User, ...
0
votes
2
answers
64
views
How do I search through a long list of attributes and match it to fontawesome icon?
I have a PropertyFeatureOption model, that has data that looks like this:
+-----+-------------------------+--------+----------+---------+-------------------------+-------------------------+
| id | ...
10
votes
6
answers
4k
views
How do I count the number of records that have one or more associated object?
I have a Property model that has_many :photos. I want to count the number of properties that have one or more photo.
How do I do that?
I have tried the simple:
> Property.where('properties....
1
vote
4
answers
760
views
How to stop a nohup process running rails server on port 3000
I have started a rails server puma by using the following command.
nohup rails server &
its output was [2] 22481 along with the following:
nohup: ignoring input and appending output to 'nohup....
0
votes
3
answers
105
views
List all associated model records present in another model present in another namespace in rails
I have two models like:
class Superadmin::Company < ApplicationRecord
belongs_to :user
has_many :garments
end
2nd
class Garment < ApplicationRecord
belongs_to :company ,:class_name =&...
0
votes
2
answers
2k
views
Add a model in the present in the other namespace as foreign key
In Rails I want to include a model_id as foreign key into another model which is present in another namespcae.
I have two models as
First:
class Garment < ApplicationRecord
end
Second:
class ...
0
votes
2
answers
68
views
Delete a model present in another namespace rails
In Rails when I have made one Model as the foreign key in another model then I can delete that model while speciying its relation like:
class User < ApplicationRecord
has_many :garments, ...
0
votes
2
answers
104
views
How to get duplicate month and year matched record in rails?
I want to fetch duplicate month of record from table
I have leaves table inside of start_date column have many records my db
https://imgur.com/a/jdyxTo1
example I have 3 duplicate record in table
...
1
vote
1
answer
1k
views
Why is Rails not finding my jbuilder template or not rendering it?
I have a route that looks like this:
resources :property_searches, :path => 'search'
That generates these routes:
property_searches GET /search(.:format) ...
-1
votes
1
answer
165
views
Edit action not working on popup bootstrap modal in rails
I am beginner. I want to call edit action on bootstrap popup modal and view is fine but edit action is not working.
view
<%@leaves.each do |leave| %>
<td><a href="#" data-toggle="...
-1
votes
1
answer
184
views
How to call model method anywhere inside project without controller call?
I have model tasks inside of method name is not_completed_list have some records stored in @list variable .i need to loop that variable (@list)from view without controller how is it?
Task.rb
class ...
0
votes
1
answer
180
views
Handling session in rails
The admin has the rights to activate deactivate user account. example image link https://imgur.com/a/S9wEsQY only activated user should be login that scenario has been completed successfully(used ...
-4
votes
1
answer
170
views
How to handled database using ROR?
I have faced one problem to getting values from database using RoR. I have min 100 million data. how can i get all the data using single query and min response time?
I want to get all the customer ...
1
vote
2
answers
60
views
How do I refactor this bulky set of if statements?
I have the following code that works, but I would like it to be more DRY and elegant. It feels ugly with lots of code smells.
Ideally I don't want to use CASE statements because that doesn't feel ...
0
votes
1
answer
566
views
How do I find all the records that have a specific value of an association?
I have a property model that belongs_to :property_type.
I would like to create a scope on my Property model that finds all the records of a specific property_type.
How do I find all the property ...
1
vote
1
answer
50
views
Rails Upgrade 3.2 to 4.0: Model deprecation warning
In Rails 3.2, I have a user Model as follows->
User model
has_many :billing_invoices, :through => :user_purchases, :select => "DISTINCT billing_invoices.invoice_date,billing_invoices....
-1
votes
1
answer
99
views
How to manage many to many relation for nested fields in Ruby on Rails
class Resume < ActiveRecord::Base
has_many :user_skills, :dependent => :destroy
accepts_nested_attributes_for :user_skills, :allow_destroy => true, :reject_if => :all_blank
end
class ...