을 범위. 쇼 페이지에서 일하는 사용자를 초대하는 양식이 있습니다. 그것은 내가 보내기를 누르는 지점까지 작동합니다. 그런 다음 오류 메시지가 표시됩니다.레일 4 - - 인수 오류가 나는이 튜토리얼의 아이디어를 함께 따라하는 방법을 알아 내려고 노력하고있어 초대
wrong number of arguments (given 1, expected 0)
나는 인수가 무엇인지 알지 못합니다. 한 가지가 주어진 인수로 불리는 것이 무엇인지 확실하지 않으며 시스템에서 예상하는 내용을 알지 못합니다. 나는 논쟁이 무엇인지, 그리고 기대를 높이는 방법을 찾아 내거나 계산되는 것을 줄이기 위해 노력해야 하는지를 알아 내려고 노력해 왔습니다.
나는 인수가 무엇인지 설명하려고하는이 기사를 발견했습니다 : http://www.skorks.com/2009/08/method-arguments-in-ruby/ 그러나 주어진 모든 예제 중, 인수없이 메소드를 표시하지 않으며 인수가 실제로 무엇인지 말하지 않습니다. 나는 아직도 혼란 스럽다.
def create
@invite = Invite.new(invite_params)
@invite.sender_id = current_user.id
if @invite.save
#if the user already exists
if @invite.recipient != nil
#send a notification email
InviteMailer.existing_user_invite(@invite).deliver
#Add the user to the user group
@invite.recipient.user_groups.push(@invite.user_group)
else
InviteMailer.new_user_invite(@invite, new_user_registration_path(:invite_token => @invite.token)).deliver
end
else
# oh no, creating an new invitation failed
end
end
: 메소드를 생성
def create
@invite = Invite.new(invite_params)
@invite.sender_id = current_user.profile.id
if @invite.save
InviteMailer.existing_user_invite(@invite).deliver
@invite.recipient.project.push(@invite.project)
else
#send new user email invitation to join as a user and then as part of this team
@invite.recipient.project.push(@invite.project)
# InviteMailer.new_user_invite(@invite, new_user_registration_path(:invite_token => @invite.token)).deliver
end
# oh no, creating an new invitation failed
end
튜토리얼이 보여줍니다 : 그것은 액션을 만들어 내 초대에이 라인을 의미
def existing_user_invite
mail(
:subject => "You've been invited to join a team",
:to => '[email protected]',
:from => '[email protected]',
:html_body => ''
# :track_opens => 'true'
)
end
:에 오류 메시지에서
참고 문헌은
일반적으로 구성 요소가 무엇인지 설명하는 레일이나 루비 리소스를 찾는 것이 어렵다는 것을 알고 있습니다.
Rails 4 - Invite team mates to project
Rails 4 - Associations - adding team mates to teams
Invite_mailer.rb
class InviteMailer < ActionMailer::Base
# include Devise::Mailers::Helpers
def existing_user_invite(invite)
mail(
:subject => "You've been invited to join a research project team",
:to => '[email protected]',
:from => '[email protected]',
:html_body => ''
# :track_opens => 'true'
)
end
end
안녕하세요, Pavan, 이것을 시도했지만 "stack level too deep"오류가 발생합니다. 내가 해독 할 수있는 것으로부터, 코드가 루프에 갇혀 있기 때문에 에러가 발생한다 : 메소드 자체를 호출하는 메소드 또는 서로를 반복적으로 호출하는 두 메소드. 나는 그것이 의미하는 바가 무엇인지, 또는 논점을 추가함으로써 어떻게 될 수 있는지를 모른다. 나는 그 다음에 대해 더 많은 것을 배우려고 노력할 것이다. – Mel
@Mel은 그것을 기대하지 않았습니다. 'def existing_user_invite (invitation)' – Pavan
과 같은 인수 이름을 다른 것으로 변경해 볼 수 있습니까? (초대장)의 의미는 무엇입니까? 내가 삽입해야 할 단어가 임의적입니까? – Mel