Ruby on Rails Application view file not showing up - ruby-on-rails

i am stuck with a problem with my ruby on rails.KINDLY help me clear the problem and please provide with a good concept of it also.
Scenario :
uptil now everything was going fine till today.as per a requirement of the application i am supposed to add some static pages to an existing ROR application.basically the application is developed and is working fine and i need to add some static pages to it.i had put some static pages in the public folder and evrything was going so for smoothly.bt at a point in the application , i.e the index page of the application there is a login for the application ( not for the static pages ) and i had put that login in one of the div of those static pages (views/users/index.erb) had copy pasted the code from index.html to index.erb.so the moment i put up the address the login page is delivered and the site navigation works too.but when i click home (page of the public folder is shown up and the code of the application's login doesnt work.) i want it to show up with index.erb that's in the views folder.
i want to redirect somehow to the page in the views (views/users/index.erb) .. tried href etc cudnt work.
hope i could put the problem in a good way for a good understanding of the problem.
and i am using rubymine editor
P.S I am new to ROR .. total new.Had .NET as my domain.so please provide me with some basic tutorial links where i can systematically understand MVC and ROR.Googling dint help :(
waiting for your answers :)

RoR takes a little bit of work and understanding to grasp, mostly because there is so much too it; from "code" to "installation/configuration" to "deploy".
Sounds like you need to look up and understand "Routing" for Static Pages.
You are quite right, the default location will be "public" with the index.html page inside there. Leave that as such; as if your "Routing" is working correctly, then views/users/index.erb will show up.
Just to give you some general direction;
Add your configuration in config/routes.rb
Then use the root to: command.
My configuration: (this links to app/views/static_pages/home.html.erb)
root to: "static_pages#home"
get "static_pages/home"
That works perfectly.
You might also want to check in the "logs" folder for possible errors.

Related

Where is the default 'Login' view and corresponding controller in the template MVC Core application in VS2019

Odd one this, I must be missing something obvious but with a brand new MVC web application, with Authentication, it builds the DB migrations for the asp user tables and puts the _LoginPartial in _Layout etc. and login works fine, I can login and register etc but I can't find the view or code to alter it.
I navigate to localhost:blah/Identity/Account/Login and can login, but there's no view in the project that corresponds, there's an /Areas/Identity folder but it only has /Pages under it, no /Account and there's no Login.cshtml or anything called Account anywhere in the project.
Very odd, I keep thinking I'm just being dim and will look again tomorrow but have done that a few times. I've tried searching for it but only find false matches.
I've created a brand new application from the template a few times now thinking I somehow messed up the choices in the dialogues but it seems so basic - the view is obviously somewhere as it loads up and works fine, but where's MVC getting it view from, and where is the controller it's calling ??
Similarly, I search the project for some text on the page, eg. 'Use a local account to log in', both in VS and using grep on the entire source folder but it's not anywhere.
To fill out the answer to the question behind my question - i.e. how can I customise the login page. To generate the views and code in-project, right click on the Areas/Identity folder in the project, select 'Add' and 'New Scaffolded item...', select Identity and go from there.
Trying that generated an error for me, with a Core 2.2 project; but I retried in a virgin Core 2.1 solution and it worked OK, I then transferred the added folders and files to my 2.2 solution, changed the namespaces to match and I can now alter the login form and log in with it OK.
The account management function to change the phone number also works, so seems like it's all hooked up OK, I've not tried any of the other identify functionality as yet.
Thanks again to Nkosi for the answer.

What is the proper way to set up an MVC site in IIS7?

I'm new to MVC, and I have a Sandbox site I've set up to play around with. I want to set the site up in local IIS(7) so that I don't have to debug every single time through VS.
The site (my Home Index) is located in D:\Projects\MVC\MVCLearn\MVCLearn\Views\Home
So, in IIS, the Application's Physical path is set to:
D:\Projects\MVC\MVCLearn\MVCLearn
When I run localhost/[appname], I get the "ASP.Net is a free web framework yada yada yada" welcome page. What am I missing? How can I see my app? I've done copious amounts of Google searches, and I can't find one clear, concise, step-by-step walk through for setting up an MVC site in IIS7
OOOHHHHHHHHHH, I get it!!!!!!!!
A raw URL call of the application (localhost/[appname]) defaults to the Index of the Home Controller. That, by default, launches the Home/Index.cshtml page, which IS pretty much the Welcome to ASP.Net page I was seeing! It was working correctly all along! I was getting confused... I thought that page was a landing page built into IIS or something, but that WAS my Index page! It was put there when Visual Studio built my project! The reason Debug was showing me something different was because that was taking me directly to a different controller with a different view that I was working on!

Umbraco 6 - Published page throws 404 in specific scenarios

I am running an instance of Umbraco 6.1.x and it has started throwing 404 on published pages.
My page structure is as follows,
Content
Home
About
Course
...
Component
Home
About
Course
Where component holds all resources and modules (HTML sections and stuff) for a page and using a partial view macro I dynamically load all components at runtime for a specific page.
We are facing an issue where we get 404 on every page after a full republish once we hit the HomePage. Before hitting home page they are all fine, but the moment we hit the homepage they are all throwing 404. By overriding the handlers I found out that they are hitting ~/umbraco/RenderMvc!
Any idea what can cause this?
Thanks in advance.
EDIT:
It is actually throwing:
No template exists to render the document at url '/'
considering the aforementioned scenario.
I have proper allowed template setup and property on nodes are showing the correct template associated with the respective items. Not sure why it's losing template info. I can force it to load under correct template using ?altTemplate=templateName.
Some pointers, we have a view in Views/Shared folder (apart from macro partials) tied to a surface controller.
One thing I would like to say is, we are using nested (library.RenderMacroContent with Umbraco markup) in our partial views and I have realized that the whole page throws 404 if there's a page with a link to the broken page which is broken (i.e. page got re-created and on t==e of the components is holding a link to the page with previous id). Suggestions?
did you get to the bottom of this? We're having exactly the same problem at the moment, on the same version of Umbraco.
I've noticed that when it happens, the umbraco.config becomes either corrupt or rolls back to a much, much earlier version, with all sorts of attributes missing. This lead us to believe it was a sync issue between the DB and umbraco.config.
We initially thought we had solved it by deleting App_Data > TEMP > ExamineIndex and recycling the app pool etc. Maybe give this ago, as it fixed it for a while for us, but alas, the demon has reared its ugly head once more. We are still in a full on dev stage though, so the constant changing may be complicating it further for us - perhaps it will be a fix for you.
If you have any more info, or even a fix, it would be greatly appreciated.
Cheers
EDIT:
Ok, I think I've solved this now, but only time will tell. Try emptying your recycle bin & then republish entire site.
I managed to consistently recreate the bug using IIS SEO site analysis. Each time I did this, the log threw up an error 'cannot find node id xyz', turns out that (and other) nodes were in the recycle bin. Upon emptying it the errors stopped. Good luck!

Umbraco URLs disappeared

I have about 50 pages in my Umbraco site and for some reason all of the URLs went from being based on the site structure to either just # or just the id of the page, like /1083
What would have caused that to happen and how can I fix it now?
Also, it would be nice to understand how these URLs get created if there is some method somewhere that manages it or they are in the database somewhere.
Delete the App_Data/umbraco.config file and then go into the admin and republished the whole site.
Thanks #Pauli

ASP.Net MVC 2 Areas: The partial view '...' was not found

We recently upgraded a project to MVC 2 and we'd like to use Areas but there is an issue.
We have created a new area, setup a controller, configured a route, and created a view in the correct location. When we run the code it successfully finds the route and hits the controller but when it goes to render the view there is an exception.
The web forms view engine doesn't seem to be looking in the Areas section for views. The error we're seeing is:
~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx
When it should be:
~/<AreaName>/Views/<ControllerName>/<ViewName>.aspx
~/<AreaName>/Views/<ControllerName>/<ViewName>.ascx
~/<AreaName>/Views/Shared/<ViewName>.aspx
~/<AreaName>/Views/Shared/<ViewName>.ascx
~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx
This would indicate that it's still somehow using the MVC 1 dll but we've looked carefully and can find only references to the V2 of MVC (there was a V1 reference in xVal, a third party DLL, but fixing that didn't make a difference).
I can only imagine that we missed something when we did the upgrade or that we've got some unusual edge case because there doesn't seem to be anything on the web that matches the problem we're experiencing.
What things could we look at that might help us resolve this issue?
Thanks in advance for any help provided.
Cheers,
Zac
What things could we look at that might help us resolve this issue?
Make sure Area Routes are Registered AreaRegistration.RegisterAllAreas(); are registered first. Area routes need to be registered as well.
Make sure generated URL links have the area name included as one of the arguments when using ActionLink and other related URL helpers
Sometimes just delete and re-add the Area from scratch. Sounds silly, but it works.
The related SO question on the left hand side of this page may help. I have linked one I think may be of value

Resources