Newest 'ruby-on-rails' Questions

Q&A for professional and enthusiast programmers

@user.valid? returning false when should be true

I'm testing my user model. The following test is failing: def setup @user = User.new(first_name: "John", last_name: "Doe", email: "john@example.com", password: "foobar", password_confirmation: "...

How to prevent part of HTML page from rendering in rails?

So this might be sort of a newbie question, but I have a multiple page form in my rails application, and I have the same background and title on each page of the form. I was wondering if it was ...

Django Annotate function Rails equivalent

So I'm rewriting my app from Django to Rails, & I'm current stuck on this piece of code conversations = Message.objects.filter( user=user).values('conversation').annotate( ...

Rails nested layout routes

I have the base default layout application.html.erb which all the other pages are rendered into. Now I would like to do sort of the same thing for the users page. Let s say I have /users/1/about ...

Xlsx with sidekiq how to configure it that i may download on sidekiq it

How to use xlsx with sidekiq together ? And how to set timeout that after timeout for example if time is gone go rediceted to diffrent page for single action in controllers. I used timeout in timeout....

Rails: How to search two columns by the value of check_box_tag

What I'd like to do is to search two columns by the value of one check box. steps model has place1 and place2 columns. class CreateSteps < ActiveRecord::Migration def change create_table :...

How to stub current_user in Rails 5?

How do I stub current_user in Rails 5? I expected this: @controller.stub :current_user, mock_user do end to work, but there is no @controller in ActionDispatch::IntegrationTest? I use sorcery gem ...

fetch data from service in Rails web ui [on hold]

I am new to rails. My application web site is in rails. It fetches data from sqlLight database. I want to fetch the data from a service instead of database. I am not sure how to do that.

Paperclip AWS Rails images not loading

I am working with rails 5.0, AWS (ruby 2.3 with puma) and using the paperclip gem. After deployment I saw that none of my images were displaying that were loaded into the site. I followed the steps ...

Pins not working and show error on heroku

I create first application with a book, and i got problem. I should write rails g scaffold pins description:string and then rake db:migrate heroku run rake db:migrate Now my website should ...

SQL statement working in Sqlite and not working in PostgreSQL why?

Showing /app/app/views/admin/business/_business_update_form.html.erb where line #31 raised: PG::UndefinedFunction: ERROR: operator does not exist: character varying = integer LINE 1: SELECT name, ...

Rails 4.2, render hardcoded html outside the controller, not as a template

I'm new on ror, have some sort of a beginner question I want to render a html file which is being sent from a remote server The file comes as a string representing the html file `` <html> <...

Rails 4.2, Resque, and Paperclip

I have a document model and I'm using Paperclip to upload large files. When I deployed my application to Heroku the upload process move very slow. Even after adding DelayJob the documents didn't ...

Add Free Pascal Compiler in Heroku

I have a Rails application where some features need the Free Pascal Compiler to work. Everything works fine localy, but I want to deploy this in Heroku now. There is any way to install the compiler ...

Rails Multi-Tenant Routing URL Generation

I have traditionally used subdomains to scope apps between tenants in multi-tenant rails apps. For my current project, I think hanging a customer identifier as the first part of the url is a better ...

Ruby on rails / Ampps / mysql.sock missing?

I just launch a project in Ruby on Rails, everything working until I go on : localhost:3000 An error is displayed : Unknown MySQL server host '/Applications/AMPPS/var/mysql.sock' So you'll ...

Rails, Has many through relation within seller and buyer

I am trying to build has_many :through relation within seller and buyer upon products. product.rb class Product < ActiveRecord::Base resourcify include Authority::Abilities self....

Parsing Atom Feed Returns Nil @Image Feedjira

I am parsing in entries from an atom feed, https://jobs.startupnorth.ca/jobs.atom. The entry structure is as follows, <entry> <id>tag:jobs.startupnorth.ca,2005:Job/1366865</id> ...

why is my website not deploying on heroku?

I have been learning rails for about a month and I have created my first simple static website using ruby on rails. it functions well on localhost:3000. I have pushed all the files onto GitHub and ...

Video sharing website language advice [on hold]

I want to build a video sharing website like Youtube. Please advice me what programming language or framework I can use it for? Please keep in mind i will be doing a complex search engine analysis for ...

adding a gem in gemfile causes rake db:migrate to fail

Summary: when I include a particular gem in Gemfile, rake db:setup no longer works; if I comment out that line in Gemfile, rake db:setup works again. Where do I look within the gem to find the problem?...

Recurring RecordNotFound error

My index page doesn't show any of my posts (Named here fits) However, after further troubleshooting, it appears that my posts aren't be created at all! I tried adding a brand new post(fit) and it ...

Issue in rake db:load command while switching to mysql database

I am working on a project in Rails 4,previously i was using sqlite3 as a database,i switched to mysql database and changed all its configuration in database.yml file.I also got all my migrations ...

Javascript function to update a countdown timer automatically in rails

def time_remaining Time.at(6.hours.since - Time.now) end def timer time_remaining.strftime("%H:%M:%S") end I have this in my controller, time_remaining should change every time the ...

Rails 5 - Simple_form and has_one association

models/video class Video < ApplicationRecord has_one :category, through: :video_category has_one :video_category end models/category class Category < ApplicationRecord has_many :...

Trying to use the value of one field as the label for another input field

Here's the code I have so far: <% @prayers.each do |p| %> <%= p.date %> <%= p.time %> <%= simple_form_for @prayers do |f| %> <%= f.input :name %> <% end %&...

cors error while calling airbnb api

I have been trying to use airbnb api from this link. I know it is not an official api but I really need to use it in my website. But I am getting CORS (Cross-Origin Resource Sharing) error and I ...

Rails files upload on production

I trying to upload an image on my local server with carrierwave there are no errors. But when i've tryed to upload same image on my production server i've validation errors (type of file, and empty ...

ActionController::BadRequest (Invalid request parameters: invalid %-encoding

I am working on an Ionic 2 app with Rails 5 API . I am trying to upload a file from my phone to the server. I user cordova FileTransfer plugin for this. From the FileTransfer docs The FileTransfer ...

Rails: friendly_id slug relationship

I want to create a slug for my model which depends on a column of a related model. Is that possible? Here is what I've thought: # Example::User class extend FriendlyId friendly_id user.username, use:...

How to get Heroku to recognize a yarn.lock or package.json within a subdirectory (not root)

I have a Rails application using React, Webpack, and Yarn for the client side. I have everything relating to the client side within the /client directory. This includes my yarn.lock and package.json ...

Connection Refused Error on React

I'm trying to connect my react app to a rails api, however, i can't seem to get the data. The error message is GET http://localhost//3000 net::ERR_CONNECTION_REFUSED Fetch Error :-S TypeError: ...

Rails 5 accepts_nested_attributes_for Getting Unprocessable Entity with JSON POST

I think I have all of this setup right for being able to send nested attributes, however, I keep getting 422 unprocessable entity but no error message. Here is how I have things configured: ...

How can I access Rails mountable engine helper method in main app?

I have written a helper method in my Rails mountable engine and I want to know how can I access that helper method in my main Rails app.

Reload instance var inside rack/rails route constraint

I've got a custom routing constraint. class TenantConstraints def initialize @domains = Domain.mapped_domains end def matches?(request) @domains[domain].presence end end Pretty ...

Class from installed gem not recognized by model

Within model Venue I am storing location data as a Geocoder object, which is acquired via Geocoder.search from a text input when a Venue is created. The location data object, which is of class ...

Passing variable back and sort

So I've got the result controller that passes the variable @patient Now I'd like to give it back to the controller so that it can be sorted according to the parameter that I pass with :sort code on ...

How to store and list ActiveRecord objects with different attributes?

I am currently developing a small project, it is a classifieds application. For this app I have the following requirement: we will have a set of categories, each of them will store different ...

Rails test error - ActionView::Template::Error: undefined method `country_select'

I am making a signup form with country_selector gem. The form works perfectly fine, but my tests are throwing up errors: ERROR["test_should_get_new", UsersControllerTest, 1.27725670899963] ...

Apply class on checkboxes collection

I would like to add a class on each instance of my collection. This is my checkboxes collection : .cov-pick-row.w-row = f.input_field :inspiration_image_ids, :collection => @...

Rails chat api with action cable

I have following models class Message < ApplicationRecord belongs_to :user belongs_to :event after_commit { MessageBroadcastJob.perform_later self } end class Event < ApplicationRecord ...

how can i read r_basicprofile data on rails

How can i show r_basicprofile data from omniauth-linkedin , in my layout view? Im new at rails and im trying to show this data on my application,html.erb view. i have the next codes app/controllers/...

Rails | Content inside form doesn't appear | Simple form, FuelUX

I am using fuelux's wizard for having a multi-step form (3 steps). This is my code <div class="wizard" data-initialize="wizard" id="myWizard"> <div class="steps-container"> <...

Parse enclosure image from Atom Feed with Feedjira

I've created a FeedEntry model where I store job entries parsed in from an Atom feed, that has a title, content, url, published_at and guid. The FeedEntries model looks as such, class FeedEntry < ...

How import url helpers from routes inside a engine?

Take a look at the code bellow, in special the code Artemis::Talk::Engine.routes.url_helpers, I am trying to put this on with a include in ApplicationSerializer, but not work. module Artemis module ...

Rails Database Query ROR

First of all, I am still new to ROR and I am trying to come up with more efficient way to do a database query for my datatables. My Model association class Store < ActiveRecord::Base has_many :...

Rails display chartkick graph only for particular user

This is my code to create a chartkick linechart for temperatures..... but the chart displayed displays the values entered by all the users and not just the user who is logged in..... this is in app/...

Retrieve file from S3. - Carrierwave Rails Gem

I'm implementing Carrierwave with fog storage into my Rails App. The whole purpose of this app is to store pdf articles and have the ability for anyone with access to the app to retrieve them. Right ...

Rails get a has_one relation on a has_many relation

On a product/order and feedbacks relation how to find and relate the feedbacks to product? Product Model has_many :orders end Order Model belongs_to :product belongs_to :feedback end Feedback ...

Rails - ActiveRecord - Users using same fingerprint

I want to query my psql database from my app, fingerprint used more of one user Tell me what is wrong. thanks class User < ApplicationRecord has_many :logins, class_name: 'LoginTracker' end ...
Translating... 0%