Questions tagged [ruby]

184053 questions
1

votes
0

answer
74

Views

Unable to add a class attribute to the label generated by a radio button input

I have the following configuration: # config/initializers/simple_form.rb config.item_wrapper_tag = :div config.item_wrapper_class = 'form-check' # config/initializers/simple_form_bootstrap.rb config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do...
bitsapien
1

votes
1

answer
27

Views

Bundler: Create Gem - Default Contact Info Source?

I followed this guide to build my first Ruby Gem: http://bundler.io/v1.12/guides/creating_gem.html Everything worked as expected, but I have one question: I noticed that Bundler auto-magically pulled my personal contact info from somewhere (I'm on a Mac) and used that to build the gem. An example o...
Pseudo
1

votes
1

answer
700

Views

rails activeadmin how to use action_item?

The poorly documentation saying: action_item :view, only: :show do link_to 'View on site', post_path(post) if post.published? end But it's not saying where 'post' in post_path(post) coming from. I guess in this example they are adding a 'view' custom action that will execute the view member_action i...
Ziv Barber
1

votes
1

answer
456

Views

VueJS, Apollo, Rails - Can't verify CSRF token authenticity

Here is my setup const token = $('meta[name='csrf-token']').attr('content'); const authLink = setContext((_, { headers }) => { // return the headers to the context so httpLink can read them return { headers: { ...headers, credentials: 'same-origin', 'X-CSRF-Token': token, 'authenticity_token': token...
James Klein
1

votes
0

answer
216

Views

Integrate GRPC server with Rails codebase

When the Google::Protobuf::DescriptorPool.generated_pool.build is called twice with the same message types, the error is being thrown saying that DescriptorPool has already registered message with the same name. Unable to add defs to DescriptorPool: Symtab already has a def named I see that as expec...
Marko Bogdanović
1

votes
1

answer
370

Views

Stripe in test mode not able to create bank account sometimes

I want to create stripe account through bank account and add bank account further on stripe in test mode.It's working but sometimes It's giving following error 'You cannot use a live bank account number when making transfers or debits in test mode' while using below details. Account Number :- 00012...
Pinki
1

votes
0

answer
24

Views

Neovim crashes after :help command when RubyGem is installed

Cause of the problem The problem is caused by some plugin called LustyExplorer. Normally, when I encounter some bug in Vim I always remove all plugins and customizations first. But after passing to Neovim, I forgot to do this first. Original Question I have just recently installed nvim 0.2.2 on OsX...
Mert Nuhoglu
1

votes
1

answer
60

Views

star rating image not deploying to Heroku

I am having a bit of an issue, I am using this plugin jQuery Raty (rating system), I have the star images on my assets/images folder but for some reason, the images are not showing. Any idea of what might be? I already ran rails assets:precompile because I found this answer here, but no dice. It wo...
Lucky500
1

votes
0

answer
374

Views

Rails + Unicorn + Nginx error (504 Gateway timeout)

Am struggling to resolve '504 gateway timeout' issue on my rails website on Digitalocean. I started facing this error after I reset my root password for DO droplet. Please see the unicorn.log below from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `requir...
HighOnRails
1

votes
0

answer
98

Views

Ruby on Rails: Devise login / sign up in modal not working on mobile phones

So I used the devise gem and it worked perfectly. I had a login page and a signup page. In order to improve the UX, I turned it into a modal. What did I do? I basically cut and pasted the view into a modal tag on my navbar. and left it at that. It worked perfectly on desktop, but on mobile it takes...
Gabriel Birnbaum
1

votes
0

answer
38

Views

specific javascript per view Ruby on Rails

I'm trying that not all the javascripts are used in all the htmls. The first thing i did was delete the require_tree. Then i used this line in my view false %> but i got this error. Asset was not declared to be precompiled in production. Add Rails.application.config.assets.precompile += %w( judicia...
1

votes
1

answer
238

Views

Raty star rating not showing up

So I'm following a tutorial and near 1:07:39 in the New Review page, he has rating field and a comment field. But for me, only the comment page shows up, and I've tried copying his movie controller, reviews controller and the _form.html.erb. I am using ruby on rails and using the cloud 9 editor. All...
iiRosie1
1

votes
2

answer
225

Views

JavaScript not working in rails 5 app

I want to use static javascript files without using the gems in my rails app. My application.js looks like this //= require jquery //= require bootstrap //= require owl-carousel //= require rails-ujs And all of the Js file I have to add in javascript folder without using any gem using assets pip...
dev dap
1

votes
0

answer
44

Views

Rateable can't be blank(mongoid-letsrate,Mongoid)

When I try create new User(devise) I get this error: Rateable can't be blank(mongoid-letsrate,Mongoid) Mongoid::Errors::Validations: message: Validation of User failed. summary: The following errors were found: Rateable can't be blank resolution: Try persisting the document with valid data or remove...
1

votes
0

answer
83

Views

Prawn: Remove bottom padding for text_box

Here is an example where i draw text via text_box 3 times with different fonts. anchor_point = {x: some_x, y: some_y} pdf.fill_color '000000' pdf.stroke_color 'FF0000' pdf.font Consts::Fonts::VENEER do p1 = {at: [anchor_point[:x], anchor_point[:y] + 30], w: 60, h: 17} pdf.stroke_rectangle p1[:at],...
George
1

votes
1

answer
123

Views

Problems sign up to facebook with ruby on rails

when I sign up using facebook my url is http://localhost:3000/registration then it will change to http://localhost:3000/registration#= but it wont let me login that the only thing it changes on that page just the url. Contoller class OmniauthCallbacksController < Devise::OmniauthCallbacksController...
AB74574
1

votes
2

answer
54

Views

Cannot delete record from rails console in AWS eb cli if a wrong subclass value is specified for a STI parent class

A colleague added a new record for the class 'Production' via our rails admin interface, which is the parent class via STI of the subclass 'CoProduction'. The type attribute was by mistake filled out via the rails_admin with a value that is not the specified subclass 'CoProduction', but with a wron...
Anna Costalonga
1

votes
0

answer
118

Views

Using Paperclip to upload images within a json attribute in a model in Rails 5

I'm currently using Paperclip to manage avatar uploading for users in my Rails app with Amazon S3. I also have a json attribute in other model (a column) which stores dynamic data. Sometimes this attribute will hold an image and sometimes not. What I want to achieve is to be able to upload files ins...
aleherzko
1

votes
1

answer
25

Views

Regex used rails routes

What regex is used in Rails routes such that it works cross environments. I am trying to setup a middleware such that requests coming to /:id:/show/details does a reverse proxy to wordpress.com/:id, was wondering if I can use something Rails has already built-in for this use case
Adam Young
1

votes
0

answer
157

Views

Is it possible to use IO.pipe for inter-thread communication in Ruby?

In the Ruby IO.pipe example from the documentation, a single message is passed through the processes. I wanted to do something similar, with two differences: use threads instead of processes use a pipe for ongoing messaging, not for a once-off message This is the obvious, but non-working code: rd, w...
Marcus
1

votes
0

answer
30

Views

Rails iteration (for unique ID's) and javascript, multiple forms in one view

I have a rails-app with multiple forms(edit-modals) in one (index)view. In order to avoid identical id's I gave every form and every field a unique ID by using namespace: That works well and all fields have unique ID's. Some of the fields use a js DateTime-picker that's related to the id's: $(docume...
Daniel
1

votes
1

answer
72

Views

Ruby + Python Pack [closed]

I am updating an API-Application. New Versions use buffers to communicate. There is a python-client. Messages are packed with struct.pack('!I%ds' % len(text),len(text),str(encode(text)) This translates to ruby: [text.size,text].pack('Na*') However, there are small differences. If the size of the str...
hartmut
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
50

Views

How to access Sequel result with dot operator in ruby?

I am newbie to Sequel and ruby and I have one thing need your help. In a word, I can't access database query result with dot operator. I am using sequel adapter in padrino ruby project. For example, persons = Person.all persons.each do |p| puts p.name . # this output correct person name, as 'john' e...
Web Developer
1

votes
1

answer
16

Views

How to execute .sh file in ruby on rails

I'm trying to execute .sh file in rails index action. I try exec'sh app/controllers/myscript.sh' it's execute it in terminal then stop the server! I don't know why. And I try output = system'sh app/controllers/myscript.sh' it's return true in the browser not what is in the .sh file Thanks in advanc...
yuna
1

votes
2

answer
54

Views

Rails controller fails with TypeError - “Error during failsafe response”?

Having an odd problem all of the sudden with my rails api application. I get the following errors when a client calls one of my 'get_auth_token' method. The error seems triggered by attempting to load the base application_controler class (error occurs at line 1). It's also a mystery to me why the...
user1023110
1

votes
1

answer
60

Views

How to set input tag between multiple form?

Suppose there are 2 forms in the same view, I wonder how to set input tags between the forms. Like this. = form_for @restaurant, url: {action: restaurant_path} do |r| = r.fields_for :restaurant_translations do |rt| dl.field dt = rt.label (t :restaurantname) dd = rt.text_field :restaurantname, autofo...
Noriaki Takamizawa
1

votes
1

answer
161

Views

How to load web content on turbolinks-android

I have a web app which made with Ruby on Rails and enabled Turbolinks 5 but currently, I need to make a native Android app which actually designed by Basecamp. On their GitHub repository have step by step setup I'm following this steps because here (google) is not enough help for turbolinks-android...
fool-dev
1

votes
1

answer
209

Views

Move to Rails 5.1 Unexpected token: eof (undefined) in move to Production

I'm having problems moving a Rails app that I've updated from 4.x to 5.1 into production. Works fine in development, but when I use Capistrano to move to the production environment, I get the below. Note that every post of similar issues seems to have a syntax error in their code, and while it is p...
codenoob
1

votes
1

answer
625

Views

How to create stub methods in rails 5 and minitest

I have the following code and I am trying to create a stub for it so I can place tests without it making a real order. def order client = StraightServerKit::Client.new( gateway_id: '123', secret: '123' ) o = StraightServerKit::Order.new(amount: 1) mycelium_order = client.orders.create(o) end How do...
Jamesla
1

votes
2

answer
44

Views

Rails: why can I send a single record attribute via controller to new record but not array?

Creating articles via the controller in Rails. A simple method, which more or less works; just call the method from some other place and it generates a new article via the back end and fills in the values: def test_create_briefing a = Article.new a.type_id = 27 a.status = 'published' a.headline = 'T...
Matthew Bennett
1

votes
0

answer
77

Views

Has and Belongs to many associations doesn't work

I'm getting crazy with this HABTM association. I have 2 classes class Brand < ApplicationRecord establish_connection Rails.application.config.dday_companies_database_configuration scope :default_order, -> { order :name } has_and_belongs_to_many :contents, join_table: :brands_contents, foreign_key: :...
Roberto Pezzali
1

votes
3

answer
220

Views

Save only time in rails

I have two time fields in the table i.e. start_time and end_time . When I execute MyModel.save(start_time: '12:34'), it gets saved with appending a date(Sat, 01 Jan 2000 07:25:00 UTC +00:00). I want to save time only. I am using Rails5
Chakreshwar Sharma
1

votes
1

answer
58

Views

Rake commands not working in Elastic Beanstalk production environment

I am having a tough problem with my Elastic Beanstalk environment. Any Rake commands respond with Abort testing: Your Rails environment is running in production mode!. rake db:migrate, even a simple command like rake:stats, responds the same way. On my local machine, everything works as expected....
Norm
1

votes
1

answer
474

Views

POSTing JSON body causes Rack::QueryParser::InvalidParameterError

I'm simply trying to POST a JSON content-type http request from one Rails server to another. Putting a % character in a value string in the JSON is causing the Rack::QueryParser::InvalidParameterError on the receiving server. On Server A, I use the httparty gem to perform a POST request w/ a JSON b...
choey
1

votes
1

answer
202

Views

ActiveRecord::Type::Value casting in Rails 4

We want to use the Whole Value pattern in our Rails4 application. We know that in Rails5, if we want OurModel to use a custom NameType Whole Value type for the attribute :name, we can define our custom type similar to this: class NameType < ActiveModel::Type::Value def cast(value) Name(value) end d...
Alexander Presber
1

votes
1

answer
632

Views

Overriding active admin session controller

I need to add two factor authentication for active admin. Whenever admin tries to login I need to verify them before giving access. Verification can be done either by sending OTP to email or mobile. So I need to over ride the Sessions controller for active admin devise so that I can add the function...
pawan kumar
1

votes
1

answer
317

Views

How to upload images from React Native App directly to Cloudinary using Attachinary in a Rails API

I'm trying to send a file from a mobile photo library to a Rails API and then upload it to Cloudinary using Attachinary and I'm getting the following error while doing so: Errno::ENOENT - No such file or directory @ rb_sysopen - file:///Users/hugoh/Library/Developer/CoreSimulator/Devices/7270BD44-FF...
Hugo
1

votes
1

answer
42

Views

Greater/Lower than works but equals doesn't on >= and <= on .where()

I have a Rails 4 app and I'm trying to make a simple search for my invoices with 3 optional arguments: Name of the client, Start Date, End Date. The search works fine mostly, if I put a start date and an end date it works for < and >, but eventhough i used >= and
onildo
1

votes
0

answer
41

Views

ActionView::Template::Error (First argument in form cannot contain nil or be empty): rails 5

I get the error ActionView::Template::Error (First argument in form cannot contain nil or be empty): when I click on the sign up link. I created a form partial which I then render on the new.html.erb file. The error appears to be from the users controller. Here is the code. class UsersController <...
Steven Aguilar

View additional questions