Rails `require’: cannot load such file — matrix

Matrix was removed from Ruby’s standard library in version 3.1. More info: https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/ With Ruby 3.1, matrix needs to be explicitly added to the Gemfile. You can add it manually or run something like: $ bundle add matrix After it’s added to the Gemfile, bundle your application: $ bundle install Then your application should continue … Read more

Array Attribute for Ruby Model

Create a model with a text field > rails g model Arches thearray:text invoke active_record create db/migrate/20111111174052_create_arches.rb create app/models/arches.rb invoke test_unit create test/unit/arches_test.rb create test/fixtures/arches.yml > rake db:migrate == CreateArches: migrating =================================================== — create_table(:arches) -> 0.0012s == CreateArches: migrated (0.0013s) ========================================== edit your model to make the field serialized to an array class Arches < … Read more

Rails before_filter for specific actions in controller

Create in your ApplicationController method: def check_privileges! redirect_to “https://stackoverflow.com/”, notice: ‘You dont have enough permissions to be here’ unless current_admin || current_company end And then in your controller: before_filter :check_privileges!, only: [:new, :create, :edit, :save] Or before_filter :check_privileges!, except: [:index, :show]

How to use compass with rails 3.1

UPDATE: Seems like there is a better way ! Source: http://spin.atomicobject.com/2011/07/12/sass-sprockets-compass-with-rails-3-1/ UPDATE 2(dec 2, 2011): Chris Eppstein, creator of Compass posted this Github Gist of how to integrate Compass with Rails 3.1: https://gist.github.com/1184843 I now prefer this method over mine, as I noticed a great speed improvement at compilation time when using livereload. MY METHOD: … Read more

what is the difference between link_to, redirect_to, and render?

link_to is used in your view, and generates html code for a link <%= link_to “Google”, “http://google.com” %> This will generate in your view the following html <a href=”http://google.com”>Google</a> redirect_to and render are used in your controller to reply to a request. redirect_to will simply redirect the request to a new URL, if in your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)