All threads / Virtual Attributes And Rails 5 Attribute API Discussion
Ask A Question


You’re not receiving notifications from this thread.

Virtual Attributes And Rails 5 Attribute API Discussion

Ariel Diaz Bermejo ·

Nice. I'd love to see an screencast with the ActionCable feature

Videos on how sockets, http, building a web framework, etc... All work would be awesome!!!

Mihai Baboi ·

First of all, thank you for all the knowledge sharing. Small feedback, though... You spent 27 out of 31 minutes presenting the problem, and only the rest for the solution. I understand the need for context, but I think your videos should be about the solution, not the problem. Happy holidays.

I disagree with you. I think that an approach on the problem makes you learn more. It's the old story of: "give him a fish" or "teach him how to catch a fish". But I also looked how many time was passed at that 27 minutes. And I was "WTH" LOL. I find kind of funny how difficult things can be when you are not aware of the available tools.

Interested to watch those videos! I'm also interested to watch videos about ActionCable and how to deploy Rails app that has ActionCable to Heroku.

Btw, .to_bool is not built in right? It's from this gem right?

Innokenty Longway ·

Thank you, Chris!

Andrew Cockerham ·

would definitely like videos on how rails works and web frameworks work - would be super useful!

It would be very interesting to see how rails and web framework works

Hi, web framework from scratch would be super usefull! 20 yrs ago (damn I am old:) I tried to implement my own object oriented "framework" for Borland Pascal as I was unable to learn their TurboVision. After third take I found myself that I was writing a TurboVision clone, stopped and it just clicked in my brain and I was able to use TurboVision :-)

Martin Grenfell ·

Great video, I enjoyed the discussion.

Martin Grenfell ·

Also, enjoyed the peek at the underlying rails code - not so scary after all :)

tujamaica ·


Chris Apolzon ·

I'm curious if you looked at how a boolean attribute works in an edit form (ie for a persisted record). I have a boolean virtual attribute that controls whether to advance to a file upload form - no need to persist the value in this case, but I do want it to default to false and be available on both edit and new forms.

If you try to render a form for a persisted record with a boolean (I haven't looked into what happens with other types) virtual attribute, you will get a ActiveModel::MissingAttributeError. Unfortunately the default option does not seem to work in this case, so to get around it I had to override the getter for the virtual attribute; I'm not sure if this is a bug in the current implementation or if there's something I'm missing.

Here's my override method (I originally thought I could use check self[:my_attribute] against nil but even that will throw the MissingAttributeError) - obviously the fact that I'm having to use send to access the private #attribute method feels like a code smell to me:

def my_attribute
value = send(:attribute, :my_attribute)
if !value

Thank you, man. It helped me a lot!

I don't post so much so first : thanks for the screencast on the site, I find them very valuable :)
I just stumbled upon this screencast, so I know this is an old topic but is there still any plan on this video series about building a web framework ? It would be awesome, either way I found some articles online but if anyone got some resources to point out on this topic I would really enjoy it.

Thank you so much for giving such great and valuable information.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 68,099+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.