This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/services/create_entry.rb | |
class CreateEntry | |
class NotValidEntryRecord < StandardError; end | |
def initialize(user, params) | |
@user = user | |
@params = params | |
end | |
def call | |
@entry = Entry.new(@params) | |
if @entry.valid? | |
entry = Entry.new(@params) | |
entry.user = @user | |
entry.status = EntryStatus.new( | |
@params[:status_weather], | |
@params[:status_landform] | |
) | |
entry.save! | |
else | |
raise(NotValidEntryRecord, @entry.errors.full_messages.to_sentence) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @eqbal,
I think without you adding accessor for
@entry
, the controllerEntriesController#create
is not going access the variable when is not success.