Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request headers #8

Merged
merged 23 commits into from
Aug 6, 2015
Merged

request headers #8

merged 23 commits into from
Aug 6, 2015

Conversation

Panioglo
Copy link
Member

No description provided.

@@ -6,6 +6,16 @@ def index
end

def create
@subscriber = Subscriber.where("email = ? and website_id = ?", params['email'], @current_site.id)
@error = Issue.where("description = ?", params['message'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asta nu prea are sens. description ala cel mai probabil o sa fie un backtrace sau un mesaj pe care il trimite siteu cu eroarea. Ti-am zis ca params['message'] asta nu prea are loc in momentul asta. Ce putem sa facem e sa adaugam un nou tabel cu mesajele. Si sa fie mesajele legate de issue_id si subscriber_id

app_id = request.headers['HTTP_APP_ID']
@current_site ||= Website.find_by_app_id_and_app_key(app_id, app_key)
end

def current_site
if params[:website_id] && current_member
@current_site ||= current_member.websites.where("websites.id = ?", params[:website_id]).try(:first)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hai sa facem aici altfel. Hai sa combinam in metoda asta current_site cu metoda aia set_websites_from_header. Fai aici asa:

if params[:website_id] && current_member
   @current_site ||= current_member.websites.where("websites.id = ?", params[:website_id]).try(:first)
else
   @current_site ||= Website.find_by_app_id_and_app_key(request.headers['HTTP_APP_ID'], request.headers['HTTP_APP_KEY'])
end

In felu asta nu avem nevoie de before_filter deasupra si nici de metoda aia de am facut-o acum

subscriber = current_site.subscribers.find_by(email: params[:email])
error = current_site.issues.find_by(page_title: params[:page_title])
if subscriber
subscriber = current_site.subscribers.create( email: params['email'], name: params['email'], website_id: current_site.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ai uitat sa stergi website_id

@Chocksy Chocksy merged commit 7b33bc1 into master Aug 6, 2015
@Chocksy Chocksy deleted the api_changes branch August 6, 2015 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants