RailsCasts Pro episodes are now free!

Learn more or hide this

Applic.at's Profile

GitHub User: volontarian

Site: Murd.ch

Comments by Applic.at

Avatar

Deprecation notice and advice from the author:

"Since Rails 3 came out, I have no longer used Inherited Resources. I have found that the responders abstraction and custom Rails generators offer the perfect balance between hiding and showing too much logic. That said, I suggest developers to make use of the responders gem (at github.com/plataformatec/responders) and no longer use Inherited Resources."

Avatar

You just have to put the following lines at the top of your features/support/env.rb:

require 'simplecov'
SimpleCov.start 'rails'

Avatar

There is a list of available vagrant box packages which is not including Fedora yet: http://www.vagrantbox.es/

I think you have to create your own through VirtualBox (select your operating system and version at the Create Virtual Machine Wizard, Fedora available?) in consideration of vagrant's guidelines for virtual boxes (http://vagrantup.com/docs/base_boxes.html): https://www.virtualbox.org/manual/ch01.html#gui-createvm

Then you have to package the box through vagrant: http://vagrantup.com/docs/base_boxes.html

Avatar

I think ruby users on win32 (RubyInstaller & DevKit) will have to do "gem install ffi -v=1.0.9" before "gem install vagrant". There are issues with the current version of this virtualbox - dependency: https://github.com/ffi/ffi/issues/167

On the other hand the setup of vagrant on win64 runs well through jruby: http://vagrantup.com/docs/getting-started/setup/windows_x64.html

Avatar

The ActiveRecord association User-Appointment is wrapped by a decorator through UserDecorator#appointment mentioned above, so you get a AppointmentDecorator when calling @user.appointment

Avatar

I think you have to eagerload all associations needed by your view in you controller:

ruby
@user = UserDecorator.new(User.includes(:appointment).find(params[:id]))

Then there should be no extra query when calling user_decorator.appointment.

Avatar

Maybe I would centrally put this method in ApplicationDecorator (not tested):

ruby
def element_if_present(key, attribute)
  if self.send(attribute)
    content_tag(:dt, I18n.t(key)) + content_tag(:dd, self.send(attribute))
  end
end

Then you have to call @user.element_if_present('your_scope.twitter', 'twitter') instead and also have the presenter output this container markup but only once in ApplicationDecorator.

Avatar

Like Ryan said about decorating a User - Posts assocation, you just have to create a method UserDecorator#appointment with AppointmentDecorator.new(model.appointment).