RSpec test for update in another action

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 rails change object, using the checkbox

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, -> {

Hide the navigation bar and the footer on some pages

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

Rails 4 - showing errors in a model that is not Enableecord

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

Best way to set up a common environment for using Rails

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

method not set on Ruby on Rails 4.2`

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

Undefined method & ldquo; _path & rdquo; in the rails

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

before_filter: unless & amp; namespace

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

Date ranges overlapping Mongoid and Rails

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,

attr_accessible on create only in Rails 3.2 and more

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

View an object with Ruby on Rails

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

Add custom items to the header menu in ActiveAdmin

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

url_for in the controller

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_

Problem with Association on rails 3

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

ROR editor of a video

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

How to get the post ID in the rails?

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

No itinerary corresponds to something that should work

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

Ruby / Rails Parsing Emails

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

Database strategy for more than 10,000 instances of an ERP

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

ActiveRecord does not set a date / time field

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,

Sexy validator for uniqueness with: scope constraint

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

Rails / ActiveRecord: Field Normalization

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

How to freeze the rake?

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