Activity
Ok I had created my model wrong Userbrands
instead of UserBrands
.
Its now creating the brand still, but not adding in the user_id and brand_id to the user_brands
table
I am getting this error, what could i be missing?
NameError in BrandsController#create
uninitialized constant User::UserBrand
def create
@brand = current_user.brands.new(brand_params) <--- this line?
if @brand.save
flash[:success] = "Brand added!! :D"
redirect_to root_url
Know what mate, i am sure you said about this before when i was discussing the structure of the DB lol Thanks again buddy.
Just thought that maybe I should use a branduser
table so a user can have multiple brands. Would this be better? and how would i join these together?
Hi all,
I want to save the brand_id i am creating in my users table how would i go about doing this? I currently have my code saving the brand.
def create
@brand = Brand.new(brand_params)
if @brand.save
flash[:success] = "Brand added!! :D"
redirect_to root_url
else
render 'new'
end
end
Posted in Has any installed macOS Sierra yet?
Reminder... If you do choose to install macOS Sierra, make sure you have Xcode 8 installed too. You can get this from https://developer.apple.com/xcode/downloads/ - and don't forget to install the command line tools for Xcode 8 too ;)
My point is that while the W3 Spec states that mixed case is how it should be, but this is the first time I have experienced an issue with mixed case URL's. - I can understand the need for them, but for pure usability it is a pain.
I only found this because I had my caps lock button on by accident. There are many cases where users could type a URL, for example a promo page for a site. I think I am just trying to cover all eventualities to remove potential user error. ;)
Posted in Has any installed macOS Sierra yet?
I was gonna post this earlier haha.
So tempted to install the final GM on my MacBook and see how it goes. I was running the beta but had massive issues due to brew.
Luckily my main Mac will stick on El Cap until I'm happy there will be no issues ;)
Posted in Controller naming...
Cheers Andrew,
Orders
makes much more sense :D thanks
Hi I've come across a really weird bug, not just in my project but on quite a few rails sites.
https://gorails.com/users/sign_in?redirect_to=%2F
- works fine
https://gorails.com/users/SIGN_IN?redirect_to=%2F
- Errors
Both URL's are basically the same. However they are actually quite different
This site provides one work around...
http://gehling.dk/2010/02/how-to-make-rails-routing-case-insensitive/
Posted in Controller naming...
Evening all,
So i have a question about naming controllers. Which would be best to use? MyOrder or MyOrders
Is it just the DB which get pluralised?
Chris has done some awesome casts. Some of the best I have seen, well worth the subs we pay. Plus the community is pretty cool too.
I've specialised in front most of my time, with .net backend. It got to the stage where I had really lost my passion for backend development. Rails really sparked that passion again, and now I am really loving the full stack again.
Cheers Jacob, much appreciated haha There is so much to pick up haha wish i had of started sooner, and not wasted time on .net lol
Posted in Devise: Add a select to my signup form
lol i mentioned them before in another post.
I wanted to change things like user/edit
to account but when you post the form, if there is an error it sends you to a different address.
I have the below set up for registrations, but when you post on /account
and there is an error it redirects to /signup
, ideally i want it to go back to /account
. I have debugged and seen that its the PUT
that is redirecting it - this is set in the url: registration_path(resource_name)
part of the form.
# Registration
get 'signup' => 'devise/registrations#new', :as => :new_user_registration
post 'signup' => 'devise/registrations#create', :as => :user_registration
get 'signup' => 'devise/registrations#cancel', :as => :cancel_user_registration
get 'account' => 'devise/registrations#edit', :as => :edit_user_registration
put 'signup' => 'devise/registrations#update'
patch 'signup' => 'devise/registrations#update'
delete 'signup' => 'devise/registrations#destroy'
Cheers buddy
Posted in Devise: Add a select to my signup form
I am also using 4.2.0, I'm not sure why but i had to move it :/ i am also using rails 5.0.0.1 maybe this is why?
I am having issues with devise personally. Yeah its fantastic but its a pain cause i want to set the URL's to something different and i don't like how it deals with things. Might need to roll my own version of Auth soon i think.
Also I notice you have contact_attributes maybe you could shed some light on another post of mine? I need to save data into a different table. - https://gorails.com/forum/how-do-i-save-a-field-in-a-separate-table-when-using-devise
Maybe even let me know if there is a better way, maybe using joins?
I am using devise for my users, during sign up i have an extra field i want to store in a different table in my Postgres DB. How would i go about storing this extra field?
So a company has_many users
, and users belongs_to company
.
I have a boolean field in company called is_brand
In the devise sign up form i want to be able to store the selected option of is_brand
and create a row in my companies table in the correct field in that table.
Posted in Devise: Add a select to my signup form
Be aware, things have changed!
It seems i had to now move this to my application_controller otherwise i kept getting Unpermitted parameters
Posted in Issue with devise
Its ok, i worked out that its down to my password routes :/ now to fix them hahah :D
Posted in Issue with devise
Hi all,
I am getting this error when i reset passwords - it throws to this error message. It still sends out the email, and allows me to reset the password. Any ideas whats causing this so i can fix it? Cheers
ActionController::UnknownFormat in Devise::PasswordsController#create
ActionController::UnknownFormat
(options.delete(:responder) || self.class.responder).call(self, resources, options)
else
raise ActionController::UnknownFormat
end
end