How to edit objects in Volt framework 0.9.3?

60 views Asked by At

I started playing around with the blog5 example (https://github.com/voltrb/blog5) from the Volt documentation website and tried to upgrade to Volt 0.9.0 to 0.9.3.

After changing the version number in the Gemfile, the edit functionality seems to be broken, clicking on the "Edit" link (see edit controller below) blocks the app. The same behaviour persists after changing the deprecated _id to id. Can anyone advise, what's wrong with the controller below, or what else may have changed between these Volt versions?

def new
  self.model = store._blog_posts.buffer
end

def edit
  self.model = store._blog_posts.where(_id: params._id).fetch_first.then(&:buffer)
end

def show
  self.model = store._blog_posts.where(_id: params._id).fetch_first
end

def post
end

# Save the post
def save
  model.save! do
    redirect_to '/'
  end.fail do |errors|
    flash._errors << errors.to_s
  end
end

Many tanks.

1

There are 1 answers

0
Ryan On

.fetch_first was replaced with just .first (though it should still work on .fetch_first, just with a deprecation warning, so maybe there's another issue)