A user submits a url, this is put into into article.url through the scaffold create method. I can parse the url like so:
def parse_url
elements = @article.url.split("/")
if(elements[0] == "http:")
@home = elements[2] #elements[1] will be an empty string because of the // in the URL
else
@home = elements[0]
end
end
What I would prefer to do is to parse the url after the user saves it with the create method and then insert this value into a new row in the database in the article table.