In my user model, I have a method display_name to output the user's full name. user.rb (id, first_name, last_name, email, ...) def display_name [first_name, last_name].compact.join(' ') end I'm trying to get my controller to return display_name like
I am building an application in Rails 5 that sends user inputs back to a controller called "TestsController." If the params[:answer] matches the "correct_answer" in the controller action, the "test" object, which the TestsCon
The object Task contains a boolean field complete. How to change the status of the object by pressing the checkbox? Task model: class Task < ActiveRecord::Base belongs_to :project scope :complete, -> { where(done: true) } scope :incomplete, -> {
To check what params[:_search] is and make the good transform, I am doing : _search = if params[:_search].is_a?(Hash) params[:_search] else CGI::parse(params[:_search].to_s) end end Recently I monkey path Object and wrote this part of code : class Ob
I'm building a website for my new company and want to create a landing page for my product that doesn't have a nav bar or a footer. I want to keep the landing page simple and just focus on the product. I'm coding in Ruby on Rails. Twitter Bootstrap i
I have a tableless model (i.e not saving in the DB), in order to manage a form. After following the instruction set in a Railscast episode, it's mostly working: class PaymentRequest include ActiveModel::Validations include ActiveModel::Conversion ext
I would like to work on a ruby on rails project with a group of 4 people. If we install rails 4.2.0 how can we ensure that we all share the same environment? Is the only option to have install VM? or is there some other way? I mean what if one user i
Its my first time asking a question here. I know i must be missing something very trivial here but have been unable to sort it out for a while now. I'm new to rails. I have 4 classes, Terminal belongs_to Port, Ports belong to_Country and Countries be
I have a JSON File which looks like: {"business_id": "vcNAWiLM4dR7D2nwwJ7nCA", "full_address": "4840 E Indian School Rd\nSte 101\nPhoenix, AZ 85018", "hours": {"Tuesday": {"close": &quo
I am trying to create a new model and provide user a link to a form to fill the model object. My model (/models/paypal_order): class PaypalOrder < ActiveRecord::Base attr_accessor :card_number, :card_verification end My controller (controllers/paypal
I'm trying to do the following: before_filter :authenticate_user!, :unless => (:devise_controller? || self.class.parent == 'admin') devise_controller? bit works (I think!) but I'm struggling with getting it to correctly detect the namespace (I'm usin
A Team Captain must be created by an Admin. once created, a Team Captain can then create the rest of his/her Team by adding members. Does it make more sense to have a separate Team Captain table or just to assign a Team Member Role (captain or member
I'm working on a project that places "bookings" for a particular property. In order to prevent a property from being double booked, I am trying to return a result of properties that are unavailable during a given time frame. In my Booking model,
Is there way to say in Rails model that the attribute is accessible only if creating new record but when updating not? something like: class DesiredModel < ActiveRecord::Base attr_accessible :type, :only => [:create] # this is just example attr_acce
I have some JSON that looks like this. I have it stored and read into an object, @items. [ { { "id": "A", "description": "a_description" }, { "id": "B", "description": "b_descripti
requirement: i want a button to reset the password of any user to "password" in the users#index page what i've tried: i didnt need a show action! so i replaced the name of show in the view as "reset password" and in the user_controller
I want to add a link like link_to ("Edit yout profile", edit_user (current_user)) at header in ActiveAdmin. Is that possible ?!Recent versions of ActiveAdmin allow you to do this in your active_admin.rb initializer: config.namespace :admin do |a
in a rails 2 controller i get some data from a model @company = Company.first and generate the url in the view <%= url_for @company %> Of course this works fine. But when i try to use this in a script include ActionController::UrlWriter default_url_
For the set of Foobars with the following ids: 1 2 3 5 7 9 11 15 18 19 22 23 I need a way to return the Foobars with the following ids, based on ActiveRecord: baz(1) -> 1 2 3 5 7 9 11 baz(9) -> 3 5 7 9 11 15 18 baz(22) -> 9 11 15 18 19 22 23 This
View <%= form_for @product, :url => admin_products_path do |f| %> <div> <%= f.label :name %> <%= f.text_field :name %> </div> <div> <%= f.label :description %> <%= f.text_area :description, :rows => 7 %&g
I've just came across a tutorial on sending emails using rails. http://railscasts.com/episodes/61-sending-email?autoplay=true I really liked the editor. What the name of it?Textmate. FYI, not sure of your platform, but it is only available for Mac OS
This is is how I have my models define for a simple blog def User has_many :comments, :dependent => :destroy has_many :posts end def Post belongs_to :user has_many :comments end def Comment belongs_to :user belongs_to :post end In my Post Controller
I have: <%= button_to 'Remove', remove_attendee_event_path(:event_id => @event.id, :user_id => user.id), :method => :post %> in one partial and it works fine. Then, in another partial in the same view, I tried to copy/paste this code while
I think this may be a pretty simple ActiveRecord problem to solve but if I have a query like: @store = Store.find params[:id] @categories = @store.categories.all where say @categories = @store.categories.all returns like 3 objects. I then want to do
I'm currently using the following to parse emails: def parse_emails(emails) valid_emails, invalid_emails = [], [] unless emails.nil? emails.split(/, ?/).each do |full_email| unless full_email.blank? if full_email.index(/\<.+\>/) email = full_email.m
I have a moderately large rails ERP application having around 80 tables . I use MySQL . I recently received a client requirement which needs me to deploy the same application for roughly 10,000 offices(an instance for each office). The central office
I have a datetime field called time in my MotionRecord model. I try to set it using this command: MotionRecord.create({:time=> "2010-10-15 15:10:24", :chart_id=>1}) Oddly enough this results in the following input: <MotionRecord id: 1,
In a Ruby on Rails 3 application, I have invitations. Here is the model: class TeamInvitation < ActiveRecord::Base belongs_to :team validates :email, :presence => true, :format => RFC822::EMAIL validates_uniqueness_of :email, :scope => :team_i
I'm trying to remove the commas from a field in a model. I want the user to type a number, i.e. 10,000 and that number should be stored in the database as 10000. I was hoping that I could do some model-side normalization to remove the comma. I don't
I have a rails-app (2.3.2) that I need to install on a server on which rake isn't installed, and on which I haven't got privileges to install gems, so I'd like to freeze the rails gem. However, I can't figure out how to do that. I've put it in the de