Questions tagged [ruby-on-rails-3]

28849 questions
1

votes
1

answer
1.3k

Views

Whats the most efficient way to update a partial after an AJAX form submit in Rails 3

I have a page with code as follows: where form is a form for '@item' and 'render @item' renders a partial that represents '@item'. The form uses remote: :true and submits using AJAX. Whats the simplest and most efficient way in rails 3 to update the entire @item partial when the form is submitted.
Ryan Perera
0

votes
0

answer
5

Views

Do partial variables override helper methods?

I have some helper method that called current_language and sometimes I send current_language in the local_assigns. So I want to assign my partial variable by the local_assigns's current_language in case if it's sent. But I found something weird, in the following code: In line 3 when debugging curren...
Ahmed Salah
1

votes
3

answer
56

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.out' But now I have forget the returned process id, so how can I detect the process id so as to delete the...
vidur punj
1

votes
1

answer
62

Views

Rails: elsif && conditional statement in controller action not working

I am working on a multistep form, which is based on Ryan Bates' #217 Multistep Forms tutorial. I needed to implement conditional navigation inside the form and things became quite complex. Navigation inside the form is working but I have problems with the conditions in my controller relative to the...
SEJU
1

votes
3

answer
775

Views

How do I access an instance variable from another controller?

So I have two models & controllers. Projects and Designers. In my designers index view, I want it to show a list of all the projects that the designer has. However, when I do a simple query like this: 'Are you sure?', :method => :delete %> From the index.html.erb in the Designers view, it gives me t...
marcamillion
1

votes
1

answer
1.5k

Views

In state_machine, how do I find which events are valid from the current state?

I am using Aaron Pfeifer's state_machine gem in my Rails3 app -- it's nifty. How do get a list of events are legal in the current state? By this, I do not mean my_model.state_path.events which returns all events transitively traceable from the current state -- I want only those that are available...
fearless_fool
1

votes
2

answer
404

Views

Using number_with_precision in Ruby on Rails 3.0.5 on numbers with large precision

I am working on a Ruby-on-Rails 3.0.5 application, which has numerous numeric fields. It has been decreed by those above, that all numeric 'quantity' fields be stored with a precision of 15 (i.e. 15 digits after the decimal place). In one particular field, the number stored is 99999.999999999900000...
Tim C
1

votes
1

answer
357

Views

Rails 5 - How to get serializable_hash for activerecord?

In rails 5, I am trying to get a data in serializable_hash format. First set of data format is in correct but second set of data is in different format. The Comment module works like parent and children format, one comment has_many comments by adding parent_comment_id. For parent comment, now data...
Shruthi R
1

votes
0

answer
47

Views

Ruby on Rails Rollback except a given model

I am running on Rails 3.2.22 and I can't get transaction/rollback working. This code should always print 'WORLD' but actually, it will never work if raise is called. But according to Rails doc, it should always reach there. My question is - is there a way how to save @pb status into a database? If I...
George Morris
1

votes
1

answer
61

Views

Find all Users that bought their car before they were 18

I want to find all Users that bought their car before they were 18. I need a query like this: User.includes(:car) .where(car: { bought_at < (user.birthday + 18.years)}) How can I write such an query in Rails 5 with Postgresql? Thank you
John Smith
1

votes
0

answer
83

Views

rails google chart bar chart vAxis label using half of width on mobile

I have a chart that display good on desktop but on mobile/small screen (phone) the label on the v axis is cut off (see image). How can i shrink the graph so that the chart uses 50% of the width while the labels use the other 50% of the chartArea so that the label can be shown full length and not cut...
mamesaye
1

votes
0

answer
118

Views

Best way to generate large Zip File in Rails

I am generating Zip File in background process (sidekiq) by downloading pictures from S3 url and then uploading & sending the download ZIP link via email. Production EC2 instance has 16GB RAM. It succeeds for 10 GB album and shows buff/cache (10GB) but will the same process crash for album size grea...
Dave
1

votes
0

answer
443

Views

mysql2 Gem::Ext::BuildError: ERROR: Failed to build gem native extension

When I download the rails application from github https://github.com/ari/jobsworth An then give bundle install it throws error: Gem::Ext::BuildError: ERROR: Failed to build gem native extension. An error occurred while installing mysql2 (0.4.4), and Bundler cannot continue. Make sure that `gem insta...
Tech Geek
1

votes
0

answer
22

Views

How to do real-time hits between two servers?

I have server A which is rails-app-1. There is another service B which is also in rails. Lets say it as rails-app-2. Records for one model(Ex: Book) in rails-app-1 can be created/updated frequently. Everytime the the record is created in rails-app-1 we have to notify rails-app-2. Normal procedure of...
Sk. Irfan
1

votes
0

answer
883

Views

How to remove Failed to create chart: can't acquire context from the given item error while using it with Ruby on Rails?

I installed frappe charts for ruby on rails through gem. Then I tried to run one of the frappe-chart code which is given in their website: let data = { labels: ['12am-3am', '3am-6am', '6am-9am', '9am-12pm', '12pm-3pm', '3pm-6pm', '6pm-9pm', '9pm-12am'], datasets: [ { title: 'Some Data', values...
Souravirus
1

votes
0

answer
34

Views

Error with rails and active admin filter, when filter 'in' is empty

how are you? I have a problem with ActiveAdmin, I have a view where I have filterts to search specific records. Like this filters: filter :has_open_offers_in, as: :select, label: 'Has buyer offers?', collection: ['Yes', 'No'] filter :expiring_tonight_in, as: :select, label: 'Expires tonight?', colle...
facundo espinosa
1

votes
2

answer
561

Views

Active Admin Show Page for one model is not working

I am integrating Active Admin into a Ruby on Rails app. I registered all my models and already set up index, filter and show for all the models. Everything is working, but for one model the admin/show page is not running. When calling the show page from the admin/index page, I get: NoMethodError in...
SEJU
1

votes
0

answer
60

Views

Chunk upload media to twitter uisng ruby 1.9.3

I am uploading large video to Twitter and getting erros media = File.open('/home/geobeats/Downloads/test.mp4', 'rb') segment_id = 0 bytes_sent = 0 access_token = Oauth::Twitter.new.access_token resp_1 = access_token.post('https://upload.twitter.com/1.1/media/upload.json', {command: 'INIT', media_t...
Mihir Kumar Thakur
1

votes
0

answer
287

Views

Create data with multiple nested attributes in rails

I am trying to create an item with nested attributes, these are my tables: Item has_many :items_modifier_groups, dependent: :destroy has_many :items_modifier_group_items, dependent: :destroy attr_accessible :items_modifier_groups_attributes, :items_modifier_group_items_attributes accepts_nested_attr...
django
1

votes
0

answer
52

Views

How to pass keyword parameter to ruby rufus scheduler?

I am learning about redmine. I am trying to receive email with rufus scheduler as explain here http://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails#Schedule-email-receiving-with-Rufus-Scheduler I don't understand how to pass the parameter to scheduler like project, traker, allow_over...
Amit
1

votes
0

answer
124

Views

Rails - Active Record validations and mark_for_destruction

I'm running on Rails 3.2.22.5 and I can't find any documentation that states whether or not child objects (that have mark_for_destruction set to true) will still have Active Record validations run against them. Example: class Parent < ActiveRecord::Base has_many :children validates_presence_of :chil...
mstrom
1

votes
0

answer
26

Views

How to get all records with specific enum in a simple_enum rails 3

spotlight.rb as_enum :media_type, :image => 0,:video => 1 When I do Spotlight.last.media_type return nil. But when I do Spotlight.last.image? it returns true 2nd issue is that it not returns list of all records when I do Spotlight.images Spotlight.videos
Haseeb Ahmad
1

votes
1

answer
17

Views

Defining functionally identical models using similar databases in Rails 3.2

I've got a database with an old schema that I'm going to be migrating data from. The table names and relationships are identical to the database. For some reason when I define the models for the old instance, they are acting as though they're the models of the new database. from_db.rb class FromDB...
Joshua Hunter
1

votes
0

answer
144

Views

Execute javascript code in Ruby

Just need to execute the below javascript and get the variable values. var u = http://track.fk; var u2 = g.tv/2grc4?track=pub3878f5a9bae34c50a9f3ab0b59e1022e&pubid=8afa71db&aff_sub=pub3878f5a9bae34c50a9f3ab0b59e1022e; var link = document.getElementById(click); setTimeout(function() { link.href = u+u...
petspanda D
1

votes
0

answer
26

Views

NameError (uninitialized constant Twitter::TextExtractor):

I am getting error while using Twitter-text gem. I am getting -> NameError (uninitialized constant Twitter::TextExtractor) while creating entry. here is the right code below class EntryParser class DEFAULT_LIST_CLASS, :username_class => DEFAULT_USERNAME_CLASS, :hashtag_class => DEFAULT_HASHTAG_CLA...
P_M
1

votes
2

answer
40

Views

Rails eager load custom has_many on index

Ruby 2.1, Rails 3.2 I've got this relationship in my project model scope :active, -> { where( deleted_at: nil ) } has_many :foremen, class_name: 'ProjectsUser', conditions: ['current_foreman = 1'] in the controller: @projects = Project.includes(:foremen).active which generates this SQL ProjectsUse...
Andrew Algard
1

votes
0

answer
32

Views

Multiple image Uploader using carrierwave for single model

I have created a gallery module and i have added two uploaders for single model. The code works fine but the when i upload the multiple images and try to edit that I get multiple options for uploading the same image. How do I fix that? Can we use two uploaders for same model or do we have some other...
Sahil Omer
1

votes
1

answer
50

Views

How to implement Parent Categories, Categories and Subcategories using self referencing controller in Rails 4

I am trying to implement a three level deep association using self referencing. Cat1 Sub1 SubSub1 SubSub2 Sub2 Cat2 Sub1 Cat3 Sub1 Sub2 SubSub1 I am able to get the child category of a category by this relation: class Category < ActiveRecord::Base has_many :sub_categories, class_name: 'Category', fo...
Ritesh Ranjan
1

votes
0

answer
188

Views

Rails 5.2: GCP deployment fails after starting to use the new encrypted credentials feature

I'm facing quite a strange issue with GCP (Google Cloud Platform) deployments. I've recently updated my Ruby on Rails application to 5.2 (was 5.1.4 previously) and I started using the the encrypted credentials feature (which I believe is amazing, to be honest), but it looks like GCP is not that happ...
1

votes
1

answer
87

Views

Error from inside ActionView::Template::Error - String can't be coerced into Integer

We recently updated the ruby and rubygems versions of our app, and we've been consistently getting the following error: A TypeError occurred in [model]#[view]: String can't be coerced into Integer vendor/bundle/ruby/2.5.0/gems/actionpack-3.2.22.5/lib/action_view/template/error.rb:92:in `+' Here is t...
Tim Maher
1

votes
1

answer
111

Views

Rails rendering why have to call .to_json

I work on a Rails API, and I want to render some binary in json. To do that I convert my binary in hex to render it. So I have # (byebug) play_card.to_json {'id'=>3, 'card_id'=>12, 'atk'=>10, 'hp'=>9, 'deck_id'=>nil, 'game_id'=>nil, 'uid'=>'2e646b8a', 'created_at'=>Wed, 06 Jun 2018 17:17:25 CEST +0...
Alexis CHEVREUX
1

votes
1

answer
45

Views

Series of new, mysterious ActiveRecord errors introduced into production environment

I have rails 3.2.13 app that I've had active and online for 5 years now. A couple weeks ago, I made some minimal changes (html/css changes in views), and ever since then, all my deploys to AWS have been seemingly corrupted. I'm getting a series of ActiveRecord or rendering errors which appeared to h...
D-Nice
1

votes
0

answer
34

Views

Know original IP address of user when request coming from a web proxy

Context I am working on an application which detects the user's IP address from the request and restricts them from doing certain actions on a page based on the country they are in. Problem When a user makes a request to our application via some Web proxy, we are unable to fetch the original IP addr...
Jagdeep Singh
1

votes
0

answer
79

Views

Form submit creates GET call instead of POST call in Ruby on mobile view

I have searched through various answers but none have worked for me so far. So here is my form which is working fine when I do a form submission from web view, but on mobile the form automatically does a GET call instead of POST call. However when I remove, target: :_blank, it works fine on mobile....
Tanmay Jain
1

votes
2

answer
437

Views

Downgrading Ruby Version for my Rails App

I'm trying to deploy my app 'project'. It's written in Ruby using Rails and it says I need to downgrade Ruby from 2.5.1 to 2.4.0. I've tried a mix of tinkering with my Gemfile and some RVM commands in my Terminal but nothing seems to work. SOS pls send help! I changed the ruby v in the Gemfile to '2...
briannarelucio
1

votes
1

answer
38

Views

grouped_collection_select, Devise and Rails 5.0 custom registration issue

I'm having having some issues with custom Devise registration in Rails 5. I have 3 models with the following AR associations User (Devise) belongs_to :chapter Chapter belongs_to :country has_many :users Country has_many :chapters I created a seed file for Chapter and Country and that's working fine,...
JJ McGregor
1

votes
1

answer
49

Views

Convert ActiveRecord query to PostgreSQL query

I am trying to update this piece of rails code into raw PostgreSQL ValidationEmergency.with_deleted.where( code: 'aml_validation_failed', service_name: 'ComplyAdvantage', service_type: nil).each do |e| e.update_attributes( { service_type: 'Screening', service_id: e.message.split(', ').last.split(...
rmagnum2002
1

votes
0

answer
46

Views

Memory increases when upgrade ruby from 1.9.3 to 2.2.10

I was using Ruby 1.9.3 + Rails 3.2.22 in heroku, recently i have upgraded ruby 1.9.3 to 2.2.10 then i could see that memory is growing fast and getting memory quota, we were using performance L dynos and WEB_CONCURRENCY as 80. Will it help anything with GC Tuning? Before the upgrade memory was reach...
django
1

votes
1

answer
42

Views

Ruby Rails Excel Format Array Manipulation

I need some help/idea on how to dynamically position values in a 2D array. Basically, I have a condition that must be met and that determines which column should the value be written. This is what I have (a loop that pass conditions before writing the value): @records.each do |client| client_info =...
user1868864
1

votes
1

answer
67

Views

Add preload to a styleseet included in asset-pipeline

I have a page on my website (made on ruby on Rails), for which I want to increase the performance. I am using 'Audits' of Google Chrome to test the 'Preformance'. One of the things that I am getting in 'Opportunities' section are: 'Pre-load key requests'. What it is telling me is, to use use preload...
Yesha

View additional questions