I would like to know how I can add more properties to users in my website.
I am using the default user template that is made with a MVC project.
I tried using the answer to
this post, but I keep getting:
The model backing the 'ApplicationDbContext' context has changed since the database was created
I believe I am missing something that isn't written in that post, can anyone point me to what I need to do?
Thanks.
You have to migrate and update your DB after changing default User model in Identity. Try with that.
I have figured out the answer.
The default user identity model comes with it's own context.
Everywhere I looked, people were always creating an additional context and I thought they both worked together just fine.
Apparently You need to work with each one separately(add migrations to each, and update database with each).
Related
I'm working on an app which using core data (one app is already live on the AppStore). OK, now I want to make it fully functional for iOS8 and client also asked me to make a good change in UI and its structure so I started a complete new project and decided to code it my self. Everything works fine, then client emailed me and confirm that, new version of app should store & fetch existing values from the database if existing app will get update. I feel bad here.
I know core data migration is possible ( I read this too, but there's some glitches in my mind about this concept.
As I told, I started a new project though is it possible to add a new version of the model?
Our entities and attributes names are not same. I named it the way I want.
Our model name is same. e.g. Somename.xcdatamodel
My app will update to the existing app on the AppStore.
How I can migrate the existing core data database to the new one?
Is this possible? How?
Any suggestions and help on this would be appreciated.
Note:
I read this question, Core Data Migration: How to delete the Core Data stack? and found that there's no issue if I delete the previous model? What you suggest?
If you need to migrate and keep the existing data, you should read more about writing custom policy Core Data Versioning Guide. Read this guide completely to get to know which category your app migration falls in.
1. Lightweight migration.
2. Or you have to write your own custom policy.
As far as i can tell from the details you provided it looks like it might be a lightweight migration for which you do not have to do anything you can just add a new version to xcdatamodel and mapping models. If not then you have to write your own custom policy and mapping models.
Also make sure you test upgrade properly.
I'm building a project where the user can access a CMS like admin system (I'm using the built in login that comes with MVC 4 projects). Each site will store the data in it's own SQL CE database. I want to publish the project without any existing db, and then let Entity Framework create it for me on the first hit.
The problem is that I can't let the /Account/Register method be [AllowAnonymous], so I need to have an already existing admin account in the "Users" table.
I want to have a "superuser" account that is already there when the db gets created, and then through this account I will log in and create a user account for the customer that is going to be using the CMS.
Is this possible, or do I need to drop this idea and just publish the project with an existing db?
If you have any other smart solutions, I'm all ears!? ;)
PS. The reason why I don't want to publish the site with a db is that I might accidentally overwrite any existing data if I do some bug fixes and forget to exclude the db from the project before deployment (for already existing sites etc).
I also have it set up so the Seed method fills the database with "starup" values, so the user starts with a clean slate.
Hopefully someone have any good ideas. I've tried searching but I couldn't really find what I was looking for.
Found the solution here:
http://kevin-junghans.blogspot.se/2013/01/seeding-customizing-aspnet-mvc.html
/ Mikael
I'm trying to create a universal settings page for my rails app and I have no idea where to start. I know there are several gems that make it simple, and I've read the docs. They enable you to do something like Settings.color = "red" and your settings for color will be red! But, how do I turn this into a form, connected to the database, that the users can then change the values?
Ideally, we need a few settings, I know one of them will be a select box where they have numerous options but only one can be chosen at a time (think Active, Suspended, Disabled, etc).
This isn't really something that a model should be used for because its not a thing, right? I'm totally lost. I can make a database table, but without a model or a controller I have no idea how to just "make a form" that saves into the database - and then how do I get those values out?
Edit: The plug ins I'm referring to are similar to https://github.com/Squeegy/rails-settings and its variants. They show you how to hard code settings which is great, but don't go into how to create a form or any of the back end stuff to make it work. It's not a model so I'm totally clueless here. There's no scaffolding to work off of.
rails-settings is model based, as the readme specifically states that.
So you'd just do as per any other model-based form.
I'm trying to modify an existing Ruby on Rails project. I understand that forms and models are closely related. I'm trying to understand how to modify a form so that instead of accepting an upload, it stores a timestamp instead. So, my understanding is that I need to modify the view and the model. Is there anything else I need to modify? What happens to existing data that I have stored in ActiveRecord?
Unless you remove columns from the table with a new migration - data will be safe. It's a good practice to write tests, so when such situations occur that you need to modify something - you can test that everything still works.
Btw, I don't understand the logic that you are trying to implement. The form was uploading some file before, and you need to change that and remove the file upload and modify some timestamp in the record?
Your existing data is supposed to be fixed up with a migration, which you will need to write.
I'm new to rails, so be nice.
I'm building a "rolodex" type application, and this question is about the best way to handle creating an entity along with several relationship entities at the same time.
For (a contrived) example:
My application will have a Person model, which has_one Contact_Info model. On the create.html.erb page for Person it makes sense for the user of my appliction to create the person, and the contact_info at the same time.
It doesn't seem right to include details for creating a contact directly in the create view/controller for person. What's the rails way to handle this?
Using nested attributes is the most common way to do this.
The actual documentation is here.
You want to use "Nested Forms". There is a great example of them in this blog post.
I'm also noob, but I had a similar issue with an app. I was using a tutor at the time and he basically said it was a good example of rails being opinionated. It sounds like you want to take the create action for two different models at the same time, which may be possible but probably very hard. Id suggest considering whether your data model could be modified, or find a way to make an acceptable user flow while collecting the data in different forms.
Update: while writing this the technical answer came in. Keep in mind, its perfectly okay to take the easy route if doing so helps you get the app out the door, and especially while you're still new.