Re: [Rails] What can my user's users do for me in a multitenant multiuser blog

2018-01-26 Thread fugee ohu
On Friday, January 26, 2018 at 12:51:06 PM UTC-5, Walter Lee Davis wrote: > > > > On Jan 26, 2018, at 12:36 PM, fugee ohu > > wrote: > > > > > > > > On Friday, January 26, 2018 at 9:06:47 AM UTC-5, Walter Lee Davis wrote: > > > > > On Jan 25, 2018, at 8:41 PM, fugee ohu wrote: > > > > >

Re: [Rails] What can my user's users do for me in a multitenant multiuser blog

2018-01-26 Thread fugee ohu
On Friday, January 26, 2018 at 12:51:06 PM UTC-5, Walter Lee Davis wrote: > > > > On Jan 26, 2018, at 12:36 PM, fugee ohu > > wrote: > > > > > > > > On Friday, January 26, 2018 at 9:06:47 AM UTC-5, Walter Lee Davis wrote: > > > > > On Jan 25, 2018, at 8:41 PM, fugee ohu wrote: > > > > >

[Rails] Re: How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Prince Bansal
Thanks Walter for the help. On Friday, January 26, 2018 at 6:36:50 PM UTC+5:30, Prince Bansal wrote: > > *Hello Guys,* > > I faced a situation in Rails that I need current_user method inside model. > There is a condition that I do not have any column that is associated > with current_user in mod

Re: [Rails] What can my user's users do for me in a multitenant multiuser blog

2018-01-26 Thread Walter Lee Davis
> On Jan 26, 2018, at 12:36 PM, fugee ohu wrote: > > > > On Friday, January 26, 2018 at 9:06:47 AM UTC-5, Walter Lee Davis wrote: > > > On Jan 25, 2018, at 8:41 PM, fugee ohu wrote: > > > > Unless i'm gonna show my ads on their pages what can my user's users do for > > me in a multi tenan

Re: [Rails] How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Walter Lee Davis
> On Jan 26, 2018, at 12:36 PM, Prince Bansal wrote: > > Okay. You're not going to be able to access current_user in a model like > this. There's just no notion of who is using the app in the Model context. In > a controller or view, yes, you can do this (although I would recommend you > use

Re: [Rails] What can my user's users do for me in a multitenant multiuser blog

2018-01-26 Thread fugee ohu
On Friday, January 26, 2018 at 9:06:47 AM UTC-5, Walter Lee Davis wrote: > > > > On Jan 25, 2018, at 8:41 PM, fugee ohu > > wrote: > > > > Unless i'm gonna show my ads on their pages what can my user's users do > for me in a multi tenant multi user blog in terms of monetizing > > The whole p

[Rails] Re: How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Prince Bansal
*Okay. You're not going to be able to access current_user in a model like this. There's just no notion of who is using the app in the Model context. In a controller or view, yes, you can do this (although I would recommend you use CanCanCan or Pundit to abstract the authorization away into its o

Re: [Rails] How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Walter Lee Davis
Okay. You're not going to be able to access current_user in a model like this. There's just no notion of who is using the app in the Model context. In a controller or view, yes, you can do this (although I would recommend you use CanCanCan or Pundit to abstract the authorization away into its ow

[Rails] Re: How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Prince Bansal
Here is the code snippet. class Attendance < ApplicationRecord ATTENDANCE_EDITABLE_VALIDITY = 7 before_save :is_editable? belongs_to :attendance_detail def is_editable? errors.add(:attendance, 'modification is not allowed.') if attendance_detail.created_at.present? && (Time.zone.n

Re: [Rails] How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Walter Lee Davis
Devise is written to be model name agnostic. They use the reference name `resource` internally to mean User, Admin, ChiefPoobah, Peasant -- whatever you choose to call your user model. If you're not hacking on Devise, then you may need to look for a similar abstraction in what you are working on

Re: [Rails] overriding gem controllers and views

2018-01-26 Thread Walter Lee Davis
Right. It's even easier for a gem. Just put your templates in the same relative place within your normal rails views or controllers, properly named, and they will "shadow" the version within the gem. In most things in Rails, "nearest wins". Gems insert their code into the Rails lookup path *afte

Re: [Rails] What can my user's users do for me in a multitenant multiuser blog

2018-01-26 Thread Walter Lee Davis
> On Jan 25, 2018, at 8:41 PM, fugee ohu wrote: > > Unless i'm gonna show my ads on their pages what can my user's users do for > me in a multi tenant multi user blog in terms of monetizing The whole point of software as a service is that your users pay you to be on your platform. Ads don't

Re: [Rails] How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Mugurel Chirica
It would help if you can share the actual code, maybe we can get a better idea of what you want to achieve. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email t

Re: [Rails] How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Rodrigo Urubatan Ferreira Jardim
Current user is a session concept, are you sure you are doing things in the correct place? Maybe you are doing something in a active record hook that should be a method called by the controller... Em Sex, 26 de jan de 2018 11:06, Prince Bansal escreveu: > *Hello Guys,* > > I faced a situation i

[Rails] How can we access current_model (Devise:Here model can be User,Account etc.) method inside AR model?

2018-01-26 Thread Prince Bansal
*Hello Guys,* I faced a situation in Rails that I need current_user method inside model. There is a condition that I do not have any column that is associated with current_user in model. I do not want to declare virtual attribute in each activerecord model also do not want to set it in global v

Re: [Rails] overriding gem controllers and views

2018-01-26 Thread Mauro Locatelli
Sorry I've seen now the word 'gems' My instructions are to make override of scaffold generator. Mauro 2018-01-26 13:06 GMT+01:00 Mauro Locatelli : > Yes, you can > > *Model* > project_folder/lib/templates/active_record/model/model.rb > > *Controller* > project_folder/lib/templates/rails/scaffol

Re: [Rails] overriding gem controllers and views

2018-01-26 Thread Mauro Locatelli
Yes, you can *Model* project_folder/lib/templates/active_record/model/model.rb *Controller* project_folder/lib/templates/rails/scaffold_controller/controller.rb *Views* project_folder/lib/templates/erb/scaffold/ All the original file can be founded inside railties folder (bundle show railties)

[Rails] overriding gem controllers and views

2018-01-26 Thread fugee ohu
I can override any gem's controllers and views by creating them in my app? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@go