Here is the structure I'm working with:
app/models/model.rb
class Model < ActiveRecord::Base
attr_accessor :some_var
end
app/models/model_controller.rb
class ModelsController < ApplicationController
def show
@model = Model.find(params[:id])
@other_var
if @model.some_var.nil?
@model.some_var = "some value"
@other_var = "some value"
else
@other_var = @model.some_var
end
end
end
Whenever I run this code (e.g. the show method), the if clause is evaluated to be true (e.g. @model.some_var == nil). How do I get around this? Is there something wrong in my assumption of how attr_accessor works?