Curated list of episodes, bundled to help you on your learning path!
Videos of tech, infrastructure, hardware and software which non-instructional by nature.
Articles around software and tutorials.
Show your love and support while looking fancy.
Got a question or want to chat about a topic? Let's talk!
irb(main):001:0> a = 'b'
irb(main):002:0> a = nil if false
CurrentScope.user = current_user if user_signed_in?
CurrentScope.user = nil
resources :articles do
scope module: 'articles' do
resources :versions do
post :restore, on: :member
resources :versions, only:  do
version = Version.includes(:item).find(params[:id])
itemable = version.item
itemable.content = version.content
One thing though - you could probably use the Current
great episode :)
In application_controller when you assign current user you don't clear the user variable, so it keeps the last logged user. Take a look:
Adding brackets would do the trick: CurrentScope.user = (current_user if user_signed_in?) or:
The reason why I would prefer leaving the article out of it is that the polymorphic association in the Version table already knows who the item belongs to. So, we can look up that item and do the necessary checks. I also like this way because then we can write it one time, and not have to worry about all of the different Action Text attributes used by other models; this solution would work for all of them.
It should take the content of the version and set it to the related content. This of course would then create a new version based on this version.