Pergunta

I have an info-table (only 1 line)

Is there a way to read and update it in Rails without stuff like MyInfo.get(:all).first?

Thank you

Foi útil?

Solução

I'm not sure if this is the answer you're looking for but you don't have to use .get(:all)

ActiveRecord provides the method .first

Replace: MyInfo.get(:all).first with MyInfo.first

This is a small simplification, but what I suggest is creating a method in app/controllers/application_controller.rb like so:

def app_info
  MyInfo.first
end

That way you can call it use it easily and modify it to add/exclude information in one place.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top