alexander kehaya

Joined

900 Experience
4 Lessons Completed
0 Questions Solved

Activity

Posted in Ransack Scoping issues

Maybe I should put the search inside of the school show method?

Posted in Ransack Scoping issues

/pins?utf8=%E2%9C%93&q%5Buser_name_cont%5D=kid

That's where it takes me after I search fro /school/1

Posted in Ransack Scoping issues

Thanks for the response. I added this to the pins controller:

def index
@school = School.find(params[:id])
@q = Pin.search(params[:q]).where(school: @school)
@pins = @q.result(distinct: true).order("created_at DESC").paginate(:page => params[:page], :per_page => 10 )
respond_with(@pins)
authorize @pins
end

When I search for a student name I get this error. "Couldn't find School without an ID"

In the url on the school's home page i have /schools/1. 1 is the id but when it goes to pin/index it looses the school id. Do I need to get re configure this to all happen in the school controller?

Posted in Ransack Scoping issues

Hey everyone, Just posted this question to stack overflow but thought I'd give it a try hear. I've been trying to figure out how to scope ransack searching for a couple of weeks but haven't figured it out. Here's the link to my question. http://stackoverflow.com/questions/30578520/limiting-search-results-to-associated-model-with-ransack-gem

Any thoughts?

Posted in Multitenancy with the Apartment gem Discussion

I'm not sure how I would do that... I'll certainly need to figure that out for staging and production environments. on my development environment I ran rake db:reset and have been able to create subdomians with their separate databases. I'm still having issues:

I have users whose role == teacher (pundit gem). They are listed for the admin to create a classroom and select the appropriate teacher. The problem is that teachers (users) are showing up in both my test accounts on that list. So, i'm thinking the data isn't being rendered and/or stored in a separate db. What do you think?

Posted in Multitenancy with the Apartment gem Discussion

Hey Chris, I've started adding this to an existing application. So far I've got four "accounts" at the global level that are already created and have users for each account. I've had these on one DB up until this point. I was able to add the subdomain attribute to the account and it's stored in the db. i ran rake db:migrate and got the following: see screen shot. I've checked in the rails console and it's storing the subdomain for each account but for some reason apartment isn't finding the tenant. Any ideas?

EDIT: It is working if I create a new school from scratch..

Posted in The Params Hash | GoRails

Wow, this was a really helpful screen cast. Thanks!

Hey guys, I've been following this thread. Great topic. Chris, can't wait for the new episodes you mentioned. This is a challenge I've run into a bunch lately.

Posted in File Uploads with Refile Discussion

This worked great! Thanks!

Posted in File Uploads with Refile Discussion

Thanks that pointed me in the right direction.. needed to define the variable @samples = Sample.all.. that got it working.

Posted in File Uploads with Refile Discussion

Ok yeah I found that one, went with the easy option of copy and pasting to google spreadsheets and then downloading it as a CSV and it worked. Now running into a pundit::NotDefinedError in SamplesController#import unable to find policy NilClassPolicy for. I'm a little confused because but I think I'll figure this one out.

Thanks again for the help.

Posted in File Uploads with Refile Discussion

I just read through the post. Seems pretty daunting.. Have been trouble shooting the rails cast. it appears he's able to upload csv files by about 3 min 12seconds in. I've got everything rendering correctly but am getting this error when I submit the file for upload. invalid byte sequence in UTF-8

I've been googling around but haven't found the right solution yet. Any ideas? I'm using ruby version 2.1.2
invalid byte sequence in UTF-8..

Posted in File Uploads with Refile Discussion

Thanks for the response. I'm going through this rails cast now http://railscasts.com/episo... to see if it works but I think I'm going to get a nokogiri error. I've had it before but going to see if I can debug. Would love to see this covered on GoRails though! Would be great to understand the parsing aspect.

I'll let you know how it goes for now.

Posted in File Uploads with Refile Discussion

Can you use this to upload a CSV file and have each row render as a new object? What do you think is the best way to do this?

Posted in Search functionality for the screencasts

I just followed the ransack tutorial. got it up and running great in development but when I pushed to heroku I get this error...

Heroku logs:

2015-01-24T01:54:38.069528+00:00 app[web.1]: PG::UndefinedFunction: ERROR: operator does not exist: timestamp without time zone ~~* unknown
2015-01-24T01:54:38.069537+00:00 app[web.1]: HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
2015-01-24T01:54:38.072276+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedFunction: ERROR: operator does not exist: timestamp without time zone ~~* unknown
2015-01-24T01:54:38.072298+00:00 app[web.1]: app/controllers/pins_controller.rb:20:in `index'
2015-01-24T01:54:38.072281+00:00 app[web.1]: HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
2015-01-24T01:54:38.072301+00:00 app[web.1]:
2015-01-24T01:54:38.069538+00:00 app[web.1]: : SELECT DISTINCT "pins".* FROM "pins" LEFT OUTER JOIN "users" ON "users"."id" = "pins"."user_id" WHERE (("users"."name" ILIKE '%Bobby Romelo%' OR "pins"."created_at" ILIKE '%%'))
2015-01-24T01:54:38.072278+00:00 app[web.1]: LINE 1: ...me" ILIKE '%Bobby Romelo%' OR "pins"."created_at" ILIKE '%%'...

Any ideas on what's going on?

Posted in Using Pundit with ActiveAdmin

Thanks for the response Chris... I've ben able to get the dashboard up and running but when I try to access the admin profile for my account I get this error

unable to find scope AdminUserPolicy::Scope for AdminUser

and it highlights this line from my applicaiton.rb file
def scope
Pundit.policy_scope!(user, record.class)
end

I'm not too clear on how to define the scope for admin user. I think I either want to figure this out or I want to write something similar to what you did for devise

include pundit
after_action :verify_authorized, unless: :devise_controller?

What would I need to write to exclude all of active admin from pundit authorizations?

Posted in Using Pundit with ActiveAdmin

UPDATE: After much trial and error I figured out how to get active admin up and running with pundit. See my answer on stack overflow by clicking here. http://stackoverflow.com/questions/27883386/how-to-get-active-admin-to-work-with-pundit-after-login

update: at the bottom of this link :https://github.com/activeadmin/activeadmin/blob/master/docs/13-authorization-adapter.md

It shows you the coded needed to start using the built in pundit adapter that AA has. I'm able to get to the login page but when I try to log in I get this error.

Pundit::NotDefinedError in Admin::Dashboard#index

unable to find policy AdminUserPolicy for #AdminUser:0x007fd55b3dac10

I've created an admin_user_policy in polocies/active_admin and set everything to true. and it's still not working.

Any suggestions?

Posted in Using Pundit with ActiveAdmin

Update: I followed this and was able to get the login page to show https://gist.github.com/tomchentw/8579571

Now once logged in I'm getting a similar error Pundit::AuthorizationNotPerformedError in Admin::DashboardController#index

I guess I'm having trouble figuring out how the adapter worked to allow for access to the login page so I can recreate it for the index page and new resources that I might add.

Any suggestions?

Posted in Using Pundit with ActiveAdmin

Hey, I'm using pundit with active admin and getting this error message

Pundit::AuthorizationNotPerformedError in ActiveAdmin::Devise::SessionsController#new

In the pundit video you show us

include Pundit
after_action :verify_authorized, unless: :devise_controller?

What do I need to do so that pundit will do the same for active admin's devise controller? Second question. I need to have access to activeadmin's controller to manage permissions in the admin panel, How do I gain access or edit that controller?

Thanks for your help!

boom! that is exactly what I needed! Thanks for the help Chris!