Forums » General Forum »
problem with showing models
Added by raj ojha 152 days ago
Is there a way to show multiple models in one controller for public access? I basically have an admin area with one admin user and a front public area where I want to be able to show a list of links to static pages in a main menu on my site. Maybe I set up my lockdown init file wrong? Any help on this would be great, thanks in advance and thanks for a great gem.
I included my lockdown init file with this post, hopefully the problem lies in there.
init.rb (5.1 KB)
Replies
RE: problem with showing models - Added by Andrew Stone 152 days ago
You were redefining your permissions, take a look at the attached and try this one. Let me know how it works for you.
Thanks for using Lockdown,
andy
init.rb (5.2 KB)
RE: problem with showing models - Added by raj ojha 152 days ago
Thanks so much for your quick response, unfortunately that didn't seem to fix my problem either. I even cleared my cache and rebuilt my database to make sure everything was loaded correctly. I've attached my posts controller and my post and page model files for reference.
posts_controller.rb - posts controller (3.2 KB)
post.rb - post model (378 Bytes)
page.rb - page model (378 Bytes)
RE: problem with showing models - Added by Andrew Stone 152 days ago
Hey Raj,
Did you logout then login? I assume you're using cookie session store? The access rights are store in your session, so they may still be there.
I just want to double check this before moving forward.
thanks,
andy
RE: problem with showing models - Added by raj ojha 152 days ago
Yes, I forgot to mention that, I logged in and out and deleted my cookies as well.
Raj
RE: problem with showing models - Added by Andrew Stone 152 days ago
So if you are not logged in, you can't see:
?
Are you getting errors in your log? If so, what are they?
thanks,
-andy
RE: problem with showing models - Added by raj ojha 152 days ago
I can access all the controllers and their respective models correctly, so I can get to http://localhost:300/posts fine but if I try and list my pages in my posts index page along with the posts the pages wont show up. I didn't notice anything weird in my log file, here's the last entry
Processing PostsController#index (for 127.0.0.1 at 2008-08-06 17:22:23) [GET]
Session ID: 95476d709fc79af2a913fcbc66df6cf2
Parameters: {"action"=>"index", "controller"=>"posts"}
[4;36;1mPost Load (0.000738)[0m [0;1mSELECT * FROM "posts" ORDER BY created_at DESC LIMIT 10 OFFSET 0[0m
[4;35;1mPage Load (0.000674)[0m [0mSELECT * FROM "pages" ORDER BY position[0m
Rendering template within layouts/application
Rendering posts/index
Rendered posts/_posts (0.01233)
Rendered layouts/_actions (0.00952)
Rendered layouts/_footer (0.00001)
Completed in 0.03759 (26 reqs/sec) | Rendering: 0.02415 (64%) | DB: 0.00253 (6%) | 200 OK [http://localhost/posts]
RE: problem with showing models - Added by Andrew Stone 152 days ago
Ahh, well Lockdown doesn't do any model level restrictions. So, if you can access the pages, the your setup appears correct. You can post your posts index.html.erb and I'll take a look if you want.
RE: problem with showing models - Added by raj ojha 152 days ago
Oh ok, thanks for your help. I see lockdown has that marked for their 1.0 release, I'll try it out again then.