ruby-on-rails-5 Questions
1
Solved
I've got the following model:
class Person < ActiveRecord::Base
enum gender: [:female, :male]
...
end
Then I added the selection of the gender to its form, like this:
<%= form_for ([@pe...
Mucoprotein asked 30/3, 2017 at 11:9
1
Solved
I'm using Rails 5. I want to get text out of a Word document (.doc) so I'm using this code
text = nil
MSWordDoc::Extractor.load(file_location) do |ctl00_MainContent_List1_grdData|
text = conten...
Consueloconsuetude asked 19/3, 2017 at 21:18
2
Am i doing something wrong ? on Record update, slug is not being updated.
class Company < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: [:slugged, :finders]
def should_gene...
Honoria asked 22/1, 2015 at 6:25
1
Solved
Problem
I have Devise Omniauth-Facebook authentication. The log in with facebook works, but the Session is lost when the user goes to localhost:3000.
I have the following GEMs:
Devise 4.2.0
Rails...
Kathaleenkatharevusa asked 16/2, 2017 at 17:17
1
I have been facing problem while creating new book.
User is logged in but still it says:
1 error prohibited this book from being saved
User must exist
When i edit my book it works fine b...
Hexagram asked 13/3, 2017 at 19:44
1
Solved
Thanks a lot for your help.
I have a locations and ads table. Location has_many :ads
I perform the following query on Location Model.
@locations = Location.joins(:ads).where(@location_params.requi...
Benzine asked 13/3, 2017 at 9:46
2
Solved
Summary
Thanks a lot for your help.
I have a locations and ads table. Location has_many :ads
I would like to make a query of Location Model with a join with Ad Model, to filter entries on paramet...
Commitment asked 12/3, 2017 at 12:12
6
Solved
I'm using Rails 5. I have this in my controller model for loading a certain model subject to criteria ...
@results = MyObjectTime.joins(:my_object,
"LEFT JOIN user_my_object_time_matches on my_o...
Futhark asked 21/2, 2017 at 3:27
1
I'm using Ruby on Rails 5. I have the following code in my model ...
class User < ActiveRecord::Base
...
attr_accessor :dob_string
def dob_string
@dob_string || (self.dob ? self.dob.strft...
Alb asked 21/2, 2017 at 17:29
1
Solved
class User
has_many :posts
end
I want to render a json hash with the as_json method.
How would I order the posts in the code below by their updated_at attribute without setting a default order...
Dishman asked 27/2, 2017 at 13:9
2
Solved
I'm using Rails 5. I have the following model
class MyObject < ActiveRecord::Base
...
belongs_to :distance_unit
...
def save_with_location
transaction do
address = LocationHelper.get_add...
Doody asked 16/2, 2017 at 16:3
2
Solved
I recently came across this deprecation warning
DEPRECATION WARNING: Method size is deprecated and will be removed in Rails 5.1, as ActionController::Parameters no longer inherits from hash. Usi...
Optional asked 26/10, 2016 at 7:33
1
Solved
I have a model with a delegate method,
class Card < ApplicationRecord
has_one :meta_sm2
delegate :next_repetition,
to: :meta_sm2
end
Because the underlying model (currently is meta_sm2) m...
Trotyl asked 18/2, 2017 at 4:1
3
Solved
I originally posted this as an issue on rails_api GitHub, but am now posting it here due to inactivity.
I'm trying to use rails_admin with a Rails 5 API application. I included extra ActionControl...
Brioche asked 25/4, 2016 at 12:13
3
To create subscriptions I run:
App.room = App.cable.subscriptions.create({
channel: "RoomChannel",
roomId: roomId
}, {
connected: function() {},
disconnected: function() {},
received: funct...
Metabolism asked 1/5, 2016 at 7:21
1
Solved
I need to create a link_to to a different subdomain.
This is what I came up with:
= link_to "Link to Subdomain", root_path(subdomain: "abc", param1: "value1", param2: "value2")
It is not worki...
Throwback asked 3/2, 2017 at 0:50
3
I initially created it in rails 5 with the --api tag.
From http://edgeguides.rubyonrails.org/api_app.html,
I removed config.api_only = true
I changed
class ApplicationController < ActionCon...
Caty asked 16/4, 2016 at 21:27
2
Solved
I have some complicated PDF generation logic that requires rendering a view outside of a controller and then passing the HTML into WickedPDF:
ActionView::Base.send(:define_method, :protect_against...
Old asked 30/1, 2017 at 21:14
1
Solved
I have a User model that looks like this:
class User < ApplicationRecord
belongs_to :organization
belongs_to :department
end
The users table in the database has the two foreign keys organiz...
Threatt asked 27/1, 2017 at 7:7
3
Solved
Suppose I have a mailer that sends different emails, but is expected to be called with the same parameters. I want to process those parameters for all mailer actions. So, calling a before_action th...
Antipope asked 20/2, 2015 at 17:19
1
Solved
In Rails 5, given a relationship between two tables that involves joining them on multiple shared attributes, how can I form an association between the models corresponding to these tables?
SQL:
...
Curr asked 14/1, 2017 at 19:30
3
Solved
Rails 5.0.0.beta4 introduced a deprecation warning on routes containing dynamic :action and :controller segments:
DEPRECATION WARNING: Using a dynamic :action segment in a route is deprecated and...
Penicillium asked 3/5, 2016 at 15:48
7
I 'm using Rails 5. I have a page where a user can update their profile and if something goes wrong, they are returned to the page
def update
@user = current_user
if @user.update_attributes(use...
Pneumodynamics asked 2/1, 2017 at 23:22
2
I have a stylesheet I want to use in my HTML emails at the path:
app/vendor/assets/stylesheets/inspinia/email_templates/email-styles.css
I am using the Premailer-Rails gem for my email styling.
...
Orlandoorlanta asked 23/12, 2016 at 23:27
1
I'm getting an rbenv: 2.3.1 is not installed or not found in $HOME/.rbenv/versions/2.3.1 when trying to deploy to Digital Ocean with Capistrano.
Does rbenv look on my local machine or on the DO dr...
Isolating asked 9/1, 2017 at 1:43
© 2022 - 2024 — McMap. All rights reserved.