Questions tagged [ruby-on-rails-plugins]

136599 questions
1

votes
1

answer
298

Views

How to add a custom column which is not present in table in active admin in rails?

in my rails application, i have installed active admin. in users index page, by default, all columns are getting displayed(User table columns). I want to add a custom column called 'become user' in this users index view (which is not a column in User's table). under this column i want to display use...
John
1

votes
1

answer
265

Views

Rails 5 - how to negate a method call on a before_save callback conditional

In my Template model I have this callback: before_save :set_status, if: :is_template? private def is_template? return self.template_type == 'template' end How can I change it so that it only fires when the template_type is NOT 'template'? I tried these: 1 before_save :set_status, if: !:is_template?...
rmcsharry
1

votes
2

answer
242

Views

Rails: how to exclude post requests for a before_action in the application controller

I have a rails app. I use a before_action in my application controller to get a variable for all identified users (I use it in the header so I need it for all my views). However, it slows down all my post requests which do not need the variable. I tried to find a way googling it but couldn't find an...
AlphaNico
1

votes
1

answer
300

Views

using ruby to extract email body from Microsoft graph rest api outlook message

I am fetching emails from Outlook through Microsoft Graph or Rest Api directly from Ruby without using any Microsoft SDK. The problem I am facing is that I can't get the email message body from the response returned by Microsoft. Using the Ruby Mail gem, I have tried to parse the response by doing:...
brg
1

votes
1

answer
332

Views

Webpacker creates huge node_modules

I created a new project with Rails 5.1 and I want to use webpacker to manage my react dependencies. The problem is after installing webpacker it creates a huge 130Mb+ dir node_modules with every possible node_package. This does not make sense as default behavior. How can I configure Webpacker to onl...
Leo Net
1

votes
1

answer
414

Views

How to turn off warnings, 'ruby -w', in 'rake test'?

I have inherited a huge Rails project with hundreds of warnings, due to other peoples' sloppy coding habits, none of which I can fix. When I run an individual test suite, with ruby test/function/my_controller_test.rb, I get a clean run with no warnings. But when I run rake test, something deep in Ra...
Phlip
1

votes
2

answer
1.1k

Views

docker-compose restart connection pool full

My team and I are converting some of our infrastructure to docker using docker-compose. Everything appears to be working great the only issue I have is doing a restart it gives me a connection pool is full error. I am trying to figure out what is causing this. If I remove 2 containers or (1 complete...
Ryan Condron
1

votes
1

answer
332

Views

Rails / Webpack: TinyMCE cannot load skins (404 (Not Found))

I am working on a Rails project that has been using assets pipeline but we are currently trying to transition to webpack. I encountered a problem when attempting to get TinyMCE to work after pulling it through yarn - the text editor simply won't load. Before the transition to webpack Originally I us...
Joanna Gaudyn
1

votes
2

answer
163

Views

How to add item to json object ruby on rails?

I want to join items from 2 tables. There output: 'costs':[ { 'id':2, 'cost_name':'rent office', 'user_id':2, 'fix':true, 'amount':300300, 'created_at':'2018-11-05T18:36:19.108+06:00', 'updated_at':'2018-11-05T18:36:19.108+06:00' }, { 'id':3, 'cost_name':'new computer', 'user_id':2, 'fix':fals...
Arkhatinho
1

votes
2

answer
328

Views

File uploading with ActiveStorage in Vue.js

I'm looking to add file uploads to a Card model (including single and multiple files) using the new Rails 5.2 ActiveStorage feature. I'm stronger in Rails and am using Vue.js to pull this off - previously I would use Paperclip to handle this. However, I've setup the config/storage.yml file and neces...
VegaStudios
0

votes
1

answer
19

Views

save hash in database in ruby on rails

I'm trying to save a hash in my database but this does not work this is my table in my database create_table 'categories', force: :cascade do |t| t.string 'name', limit: 255 t.integer 'client_id', limit: 4 t.integer 'event_id', limit: 4 t.text 'color', limit: 65535 end in my model try...
Alex Cortes
1

votes
3

answer
57

Views

Object must be a Date, DateTime or Time object. nil given

Object must be a Date, DateTime or Time object. nil given. Extracted source (around line #23): when I try to save with the blank date this error occurs, is there a strong textsolution where I can save without needing to fill it? EDIT: ===============================================...
1

votes
2

answer
53

Views

How to use AWS Document DB with Ruby On Rails? Compatibility with version 3.6?

recently AWS implemented compatibility with MongoDB version 3.6 via DocumentDB. Document DB requires a certificate that can be downloaded at: https://s3-us-gov-west-1.amazonaws.com/rds-downloads/rds-GovCloud-Root-CA-2017.pem Using a configuration file similar to: https://github.com/mongodb/mongoid/...
ipegasus
1

votes
2

answer
57

Views

How to display a list of multiple model

I'm working on a social networking media like Facebook. Users can create daily posts and events. In timeline, I want to display a combined list of @post and @event. Can I build that on Rails? How about this below in controller: @feed = Post.all + Event.all And I should divide each thumbnail view als...
k10a
1

votes
3

answer
44

Views

Display counted records from partial

I have a ruby application in which I have post and like models. I want to be able to click a like button and then refresh the number of likes for the post. For that I'm using ajax. My question is how I can count the likes for the post in my partial html document. At the moment the code in my _show....
flo3719
1

votes
3

answer
98

Views

error: The branch 'upgrading' is not fully merged

I recently cloned my application from Bitbucket and checkout to a new upgrading branch where I upgraded my application from rails 5.0.0.1 to rails 5.1.6: $ git checkout -b upgrading I firstly updated my Gemfile, the I ran bundle update: $ bundle update From the railsdiff website and from a new rails...
Asarluhi
1

votes
1

answer
54

Views

Validate uniqueness of rec ord with scope, is not working properly when saving nested records

I have a model User with a many-to-many relationship to Book, through UserBook. To create a new relationship, the user can either: Select from a list of available books Create a new book request by typing in ISBN code (which can be used to look up the book), they can submit multiple requests at the...
bo-oz
1

votes
2

answer
39

Views

Ruby - automatically initialize class instance variables of child classes without inheriting the value

I am looking for a solution to automatically initialize a class variable through inheritance (make it available as an accessor and initialize it to some value). But I do NOT want to inherit the value, just start with a new fresh object each time on each class. I have been looking at class_attribute...
1

votes
1

answer
20

Views

delegate in rails active record

when digging into rails source code there are some some code in activerecord/lib/active_record/querying.rb QUERYING_METHODS = [ :find, :find_by, :find_by!, :take, :take!, :first, :first!, :last, :last!, :second, :second!, :third, :third!, :fourth, :fourth!, :fifth, :fifth!, :forty_two, :forty_two!,...
ThanksSirAlex
1

votes
3

answer
37

Views

How To Fix undefined method `product' for #<LineItem::ActiveRecord_Relation:0x0000000017b22f70>

I'm try product quantity - 1 but ı get this error line_item.rb belongs_to :order belongs_to :product payment.rb has_many :orders undefined method `product' for # LineItem::ActiveRecord_Relation:0x0000000017b22f70> @line_item = LineItem.where(:order_id => params[:zc_orderid]) @line_item.product.qua...
Mansur Berbero
1

votes
2

answer
25

Views

How to exclude items have already chosen

I'm working on the application which users can choose items but they can't choose ones have already been chosen. BoardItem has board_id and item_id. An item that was already chosen should not be included in the selected collection. Item and board have board items. @board = Board.find(params[:id]) @...
k10a
1

votes
2

answer
22

Views

Parsing a TimeZone name string that includes GMT offset hours

I did find this question but I am still stumbing around looking for a simple solution to the following: An API call returns the following format which looks like they are using Time.zone.to_s irb> ShopifyAPI::Shop.current.timezone => '(GMT-08:00) Pacific Time (US & Canada)' I would like to parse th...
kg.
1

votes
2

answer
18

Views

After save call back don't update

I am trying to set a callback for my Product Model, but the product attribute's discounted_price doesn't change... I can't call self.save it raises a stack level too deep What am I doing wrong? product.rb after_save :set_discount def set_discount self.discounted_price = self.price - (self.price * se...
johan
0

votes
2

answer
68

Views

Ruby DSL used across multiple <% %> tags or multiple lines

I am writing a helper DSL to make it easier to craft a nice menu ui within a view. The view's erb is producing an error undefined method 'safe_append=' for nil:NilClass when I break the block across multiple erb tags but it works fine if I stick it in one tag. I want to understand why -- it should...
Michael K Madison
1

votes
2

answer
1.6k

Views

Using accepts_nested_attributes_for on a join table with its own attributes - Duplicate rows

I have the following three models (Rails 2.3.8) class Outbreak < ActiveRecord::Base has_many :incidents, :dependent => :destroy has_many :locations, :through => :incidents accepts_nested_attributes_for :incidents, :allow_destroy => true accepts_nested_attributes_for :locations, :allow_destroy => tru...
Pasted
0

votes
0

answer
2

Views

Rails 6 + yarn + datatables issue

I bumped into troubles with webpacker. I'm using Rails 6.beta3 and trying to add Datatables to my app. My steps: yarn add datatables.net-dt then in app/javascript/packs/application.js: require('@rails/ujs').start() require('turbolinks').start() require('@rails/activestorage').start() require('channe...
snake
0

votes
0

answer
4

Views

Problem installing bundler, Says it installs, but then doesn't actually install

I am setting up a new system. I'm using rbenv instead of rvm because rvm changes the definition of 'cd' and that's just evil. I've got the required version of ruby and rails (I think) installed, but bundler is causing problems: turlingdrome$ gem install bundler ERROR: While executing gem ... (Errn...
Brian Postow
1

votes
1

answer
3.3k

Views

Routing Error: uninitialized constant Sessions

I'm following this Ruby Railcasts episode to get some simple auth going, and I'm getting the error uninitialized constant Sessions when I navigate to the login page. I've checked my classes and the names are proper, which seems to be the problem most people report. Any idea what might be happening h...
8vius
0

votes
0

answer
5

Views

Rails mulitple AR operations (min, max, avg.. ) on same quey object

I want to perform multiple calculations using one query to price_histories table, and finally render some statistics using those prices like average, minimum and maximum etc. price_histories_controller.rb price_stats = PriceHistory.where('created_at >= ? AND cast(item_id as integer) = ?', 1.day.ago...
Alejandro Camba
0

votes
0

answer
3

Views

How can I generate a custom script with the Rails asset pipeline?

In Rails, I want to generate some JavaScript dynamically and upload it to S3. First of course I need to generate it. I need something like: Rails.AssetPipeline.generateFile('assets/application.js', {name: 'John', age: 35}) Which would generate a string like: (function() { var data = {name: 'John', a...
Some Guy
0

votes
0

answer
4

Views

Undefined method error when calling a helper method in controller from view

When I call @certificate, @exp_date = certificate_with_date(@int, @coach) in my email template view, I get the following error: undefined method `certificate_with_date' for # In my controller, I have included helper_method :certificate_with_date This is the method in question; def certificate_with_...
the_spiranian
1

votes
2

answer
154

Views

Rails Active Record Order Issue

I have a model class named Event, and a field 'when'. I'm trying to return events order by when desc, so here is the code. @events = Event.order(''when' DESC') I'm using MySQL as the database. but the returned results is not sorted. I've looked into the console, and file the generated sql, which s...
fengd
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
2

Views

MiniTest Model Test Failing

I have a model 'Policy'. Within that model, I have presence validations for policy_holder and premium_amount. I'm attempting to write a MiniTest test for this model (I'm not very familiar with MiniTest). For some reason, my tests are failing. Here is my model: class Policy < ApplicationRecord belong...
hashrocket
0

votes
0

answer
3

Views

Rails production as daemon -d not working with Nginx

When I start rails server -b 127.0.0.1 -p 3000 -e production all is working When start with daemon option rails server -b 127.0.0.1 -p 3000 -e production -d It writes than something wrong (red window on rails website) log/production.log is empty Nginx error.log (domain changed to site.ru) - not only...
user1938361
0

votes
1

answer
18

Views

How to add a font awesome icon into a haml form submit button

I'm currently trying to add a search font-awesome icon into my forms submit button, here's what I've done so far: = simple_form_for :search, url: search_products_path, method: :post, html: { class: 'mx-auto'} do |f| = f.input :code = f.submit 'Search', :class => 'btn btn-success' do %i.fa.fa-search...
Alex Yates
1

votes
2

answer
92

Views

Passenger and rbenv issue - incompatible library version

Lately I moved from RVM to Rbenv. I run a bunch of different rails applications (each has a different ruby version) with passenger and nginx. However, I get an error for two applications when trying to load them: /user_folder/.rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:5...
Ariel Scherman
1

votes
1

answer
1.8k

Views

In Rails Devise gem how to modify the send_reset_password_instructions method?

I want to modify the send_reset_password_instructions method so that I can send some extra parameters through it to the url. Then I can read that parameter in the url and if its present I will style the view (and the mailer) in a different way. What I really need to do is send the reset password ins...
THpubs
0

votes
3

answer
24

Views

How to show the list of data at the time of search operation?

I need to show the list of data at the time of search operation. By default the list will be empty. If any search occurred that corresponding data will show in the grid. If no search occurred the list will be empty. How to achieve this using angular 6. Getting list of data i am using *ngFor. By defa...
Vinodha
7

votes
1

answer
117

Views

Converting Javascript datatables to use Opal in Rails app

I am using the ajax-datatables-rails. Below is the JS for my datatable. I want to convert the javascript into equivalent Opal.rb. jQuery(document).ready(function() { var table = $('#organizations-datatable'); var token = $('meta[name=csrf-token]').attr('content'); table.DataTable({ 'processing':...
Michael K Madison

View additional questions