Category "ruby-on-rails"

Ubuntu 18.04 can't initialize iptables table `nat', how can I fix this?

I am new to WSL, and I am trying to download prax (Rack Proxy Server for Development). I am using WSL, Ubuntu 18.04 and uname -r -- 4.4.0-19041-Microsoft I am f

Remove associations when using a Factory with associations

I have a simple :item factory with a nested attachment that is working fine. FactoryGirl.define do factory :item do before_create do |item| item.a

Add a CSS class to <%= f.submit %>

My question is easy: <%= f.submit %> Where does the class declaration go? I'm getting errors on multiple attempts.

AssociationTypeMismatch and FactoryGirl

This has been causing some frustration recently... It seems that using Factories in my cucumber tests, in some situations causes AssociationTypeMismatch error

Storing booleans in Active Record Store

I am using a standard rails form to update an ActiveRecord::Store store :settings, accessors: %i[is_public] My form looks like this: <%= form.select(:is_p

How to remove a field from params[:something]

My registration form, which is a form for the Users model, takes a string value for company. However, I have just made a change such that users belongs_to compa

How do I Listen to Select2 Events in a Stimulus Controller?

I am trying to listen to a Select2 event in a Stimulus controller via the data-action. I have a stimulus controller, where I have included an event listener for

What is the purpose of views' predefinitions in dump file

I'm working on the project where we are using :sql schema format for the Active Record dumper (to support more complex logic like triggers). We have a lot of

How can I send mail with rails without a template?

In my Rails 3 project, I want to send some simple notification emails. I don't need to make a template for them or do any logic. I just want to fire them off fr

Is it possible to set ENV variables for rails development environment in my code?

I know that I can set my ENV variables in bash via export admin_password = "secret" But is there a way to do it in my rails source code somewhere? My first a

How I can directly login to rails console through ssh?

Time to time I repeat the following commands: ssh username@servername cd /projects/rails_project bundle exec rails c production I want to create a shell scri

SMS verification after devise login, how?

I am using devise for user authentication, how i can request from user, after clicking on sign in button, to enter sms code which is automaticaly sent to his mo

fix `Missing frozen string literal comment` issue

I created a new migration, it looks like this one: class AddCommentsToUsers < ActiveRecord::Migration def change add_column :users, :comments, :text

Google Maps API not returning some postal codes (French cities)

I have an autocomplete field on my rails app, which is not returning the postal_code for some French cities, whereas they actually DO exist (and since all citie

Correct way to test Rails version for gem authoring

What is the correct way to manage conditional flow in a gem based on Rails version? Rails 4 changes some things so I need to conditionally flow based on Rails

display list of days in a week in Rails using Date::DAYNAMES

I'm having trouble displaying a list of days in a week in a form. <%= form_for [@hourable, @hour] do |f| %> <% days = [] Date::DAYNAMES.each_with

How can I make a mock of an authenticated user?

I am having trouble showing a mock logged in user in cucumber. When a user is logged in they can, make a post. My Errors: (::) failed steps (::) undefined

Rails/Rspec - testing a redirect in the controller

So I am currently writing a test for a controller in an existing controller that just didn't have one before. What I want to test is a redirect that happens whe

postgres LISTEN/NOTIFY rails

Ryan Bates mentions the LISTEN/NOTIFY functionality of Postgres when discussing push notifications in this episode, but I haven't been able to find any hint on

Parametrized join in Rails 4

I am doing manual join and I need to pass a parameter to its ON clause: Foo.joins("LEFT OUTER JOIN bars ON foos.id = bars.foo_id AND bars.baz = #{baz}") Is t