We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I have created my Resources files but I'm missing one part (still understanding how this part works)
I have a resources that PUTs a URL into my database using the following sentence =>
curl -i -H "Accept: application/vnd.api+json" -H 'Content-Type:application/vnd.api+json' -X POST -d '{"data": {"type":"urls", "attributes":{"url":"http://www.myurl.com"}}}' http://localhost:3001/api/v1/urls
My question is: How do I allow my controller (or resource) to parse the HTML and extract some tags from it?
I created the following method on my urls_controller just to test if it works:
def create @url = Url.new(params[:data]) parse_url = Nokogiri::HTML(open(params[:data][:attributes][:url].to_s)) puts parse_url.class # => Nokogiri::HTML::Document @url.save end
but my console shows this error
ActiveModel::ForbiddenAttributesError (ActiveModel::ForbiddenAttributesError): app/controllers/api/v1/urls_controller.rb:7:in `create'
and the URL is not printed on my console nor the url is saved on my urls table.
Any suggestion?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi, I have created my Resources files but I'm missing one part (still understanding how this part works)
I have a resources that PUTs a URL into my database using the following sentence =>
curl -i -H "Accept: application/vnd.api+json" -H 'Content-Type:application/vnd.api+json' -X POST -d '{"data": {"type":"urls", "attributes":{"url":"http://www.myurl.com"}}}' http://localhost:3001/api/v1/urls
My question is:
How do I allow my controller (or resource) to parse the HTML and extract some tags from it?
I created the following method on my urls_controller just to test if it works:
def create
@url = Url.new(params[:data])
parse_url = Nokogiri::HTML(open(params[:data][:attributes][:url].to_s))
puts parse_url.class # => Nokogiri::HTML::Document
@url.save
end
but my console shows this error
ActiveModel::ForbiddenAttributesError (ActiveModel::ForbiddenAttributesError):
app/controllers/api/v1/urls_controller.rb:7:in `create'
and the URL is not printed on my console nor the url is saved on my urls table.
Any suggestion?
The text was updated successfully, but these errors were encountered: