[Rails] Active record queries, reverse lookup on has_many: :through =

2012-11-26 Thread Niklas Nson
*User.rb* has_many :looking_for_whos, :class_name = UserLookingForWho has_many :asset_looking_for_whos, :through = :looking_for_whos belongs_to :asset_usertype In a controller i can do the following: *@users = User.where(asset_usertype_id: [current_user.looking_for_who_ids])* to get all

[Rails] Use of Super or how to get the calling object.

2012-05-05 Thread Niklas Nson
Class User has_many :settings, :class_name = UserSetting, :foreign_key = user_id Class UserSetting belongs_to :user In UserSetting i have class self def set(name, value) setting = [here i need the calling user object].settings.find_or_initialize_by_name(name) end end what i

Re: [Rails] Use of Super or how to get the calling object.

2012-05-05 Thread Niklas Nson
Thank you for a great answer, i wanted to move it from the User model - but i guess the smartest way is to keep it in there, also did the renaming to update_setting ... Again thank you! -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To

[Rails] Re: Join two models

2011-12-16 Thread Niklas Nson
Thanks, got it sort of working. Would like to drop ActiveRecord::Base from Post (don't want to create a table for Posts) just the TextPost and LinkPost, will work on that tonight. Thanks again. /Niklas. On 16 Dec, 11:07, Xuan xua...@gmail.com wrote: On 16 dic, 08:11, Niklas Nson niklasn

[Rails] Join two models

2011-12-15 Thread Niklas Nson
Need some help with understanding the best way of doing the following: I have a user model and two models (link_post and text_post) i now want to join the models together as post. both link_post and text_post has a user_id column. What a i want is to get u = User.first u.posts to

[Rails] Need some help with regular expression

2011-08-12 Thread Niklas Nson
I need to validate a string from a user (a location for use with geotagging) that is. I want to make sure that the user specify a city and a country in my inp ... So i wrote this = validates :usri_location, :presence = true, :format = {:with =

[Rails] Re: Need some help with regular expression

2011-08-12 Thread Niklas Nson
Thanks - this is a bookmark from now on... On 12 Aug, 15:35, Leigh Daniels leighdaniel...@gmail.com wrote: Try usinghttp://rubular.com/. I use this a lot because it's fast (most of the time) and interactive. **Leigh I need to validate a string from a user (a location for use with

[Rails] Re: Need some help with regular expression

2011-08-12 Thread Niklas Nson
Thanks for all help! On 12 Aug, 15:34, Juan Alvarado jcalva...@gmail.com wrote: On Aug 12, 2011, at 9:21 AM, Colin Law wrote: On 12 August 2011 14:08, Niklas Nson niklasn...@meantime.se wrote: I need to validate a string from a user (a location for use with geotagging) that is. I want

[Rails] Re: Need some help with regular expression

2011-08-12 Thread Niklas Nson
Thanks :) On 12 Aug, 16:19, 7stud -- li...@ruby-forum.com wrote: Juan Alvarado wrote in post #1016383: On Aug 12, 2011, at 9:21 AM, Colin Law wrote: On 12 August 2011 14:08, Niklas Nson niklasn...@meantime.se wrote: I need to validate a string from a user (a location for use

[Rails] Re: Rails 3.1 + jQuery + jQuery UI = data is null

2011-07-07 Thread Niklas Nson
If i remove //= require_tree . it works... On 7 Juli, 07:49, Niklas Nson niklasn...@meantime.se wrote: Trying to get jQuery UI to work with my rails 3.1 setup, but i keep getting errors that i cant see posted anywhere, this is driving my insane so please have a look = [application.js

[Rails] Rails 3.1 + jQuery + jQuery UI = data is null

2011-07-06 Thread Niklas Nson
Trying to get jQuery UI to work with my rails 3.1 setup, but i keep getting errors that i cant see posted anywhere, this is driving my insane so please have a look = [application.js] // This is a manifest file that'll be compiled into including all the files listed below. // Add new

[Rails] Application design question (Application Theory)

2011-06-06 Thread Niklas Nson
This is currentlymaking my head spin, and it looks like i cant get a clear answer: so im turning to you. In my sandbox application i have users and these have profiles: in profiles i store information like a about me and country, state and city. And some other information (all who the user select

[Rails] Re: Application design question (Application Theory)

2011-06-06 Thread Niklas Nson
, or is the ghost_of_many_sql_questions just in my head ? On 6 Juni, 18:03, Walter Davis wa...@wdstudio.com wrote: On Jun 6, 2011, at 10:45 AM, Niklas Nson wrote: This is currentlymaking my head spin, and it looks like i cant get a clear answer: so im turning to you. In my sandbox application i have

[Rails] Can you use meta_search from diffrent models ?

2011-05-24 Thread Niklas Nson
Im in love with meta_search, a great gem but i have a question: when using it in controllers wich has the same name as the model (Photo = PhotosController) it workes like a charm. But i have a PeoplesController for handling accounts, profiles etc - and if i try to use it there i get an error of:

[Rails] Re: Can you use meta_search from diffrent models ?

2011-05-24 Thread Niklas Nson
, 17:05, David Kahn d...@structuralartistry.com wrote: On Tue, May 24, 2011 at 9:35 AM, Niklas Nson niklasn...@meantime.se wrote: Im in love with meta_search, a great gem but i have a question: when using it in controllers wich has the same name as the model (Photo = PhotosController

[Rails] Re: Can you use meta_search from diffrent models ?

2011-05-24 Thread Niklas Nson
, Niklas Nson niklasn...@meantime.sewrote: Thanks for your reply - sadly i cant get it working. :routes = match /peoples = peoples#index, :as = peoples Both accounts_ and _account results in undefined method `account(s)_screen_name_contains' for #ActiveRecord::Relation:0x106ae3da8 Can i

[Rails] Re: Can you use meta_search from diffrent models ?

2011-05-24 Thread Niklas Nson
And no way of letting the PeopleController letting it know that it should user Accounts ? /Niklas. On 24 Maj, 20:30, David Kahn d...@structuralartistry.com wrote: On Tue, May 24, 2011 at 1:14 PM, Niklas Nson niklasn...@meantime.se wrote: I think i have mislead you with the subject line

[Rails] Re: Can you use meta_search from diffrent models ?

2011-05-24 Thread Niklas Nson
was in that Account was the model and then a PeoplesController. But after your last message i think this should not matter ? Grateful for all help, /Niklas. On 24 Maj, 21:30, David Kahn d...@structuralartistry.com wrote: On Tue, May 24, 2011 at 1:55 PM, Niklas Nson niklasn...@meantime.se wrote: And no way

[Rails] Re: Can you use meta_search from diffrent models ?

2011-05-24 Thread Niklas Nson
Kahn d...@structuralartistry.com wrote: On Tue, May 24, 2011 at 3:05 PM, Niklas Nson niklasn...@meantime.se wrote: This is what i got: class PeoplesController ApplicationController   def index    @search = Account.search(params[:search])    @users = @search.where(:status = active

[Rails] Re: polymorphic reference deeper ?

2011-05-22 Thread Niklas Nson
, Niklas Nson niklasn...@meantime.se wrote: I have made myself a small activity model like this = # == Schema Information # Schema version: 20110519174324 # # Table name: activities # #  id         :integer         not null, primary key #  account_id :integer #  action     :string

[Rails] Re: polymorphic reference deeper ?

2011-05-22 Thread Niklas Nson
Got it working, you are my hero! On 21 Maj, 17:00, Matt Jones al2o...@gmail.com wrote: On May 20, 11:48 am, Niklas Nson niklasn...@meantime.se wrote: I have made myself a small activity model like this = # == Schema Information # Schema version: 20110519174324 # # Table name

[Rails] polymorphic reference deeper ?

2011-05-20 Thread Niklas Nson
I have made myself a small activity model like this = # == Schema Information # Schema version: 20110519174324 # # Table name: activities # # id :integer not null, primary key # account_id :integer # action :string(255) # item_id:integer # item_type :string(255) #

[Rails] Simple_Form and Simple_Fields_For and working in Form_Tag, Fields_For

2011-05-02 Thread Niklas Nson
I have this form and i got it working as i want: %= form_tag(update_individual_photos_path, :method = put) do % %= fields_for photos[], @photo do |f| % . % end -% %= submit_tag(Post) % % end % But i would like to move to doing this with simple_form_for and

[Rails] Form's and Actions.

2011-04-19 Thread Niklas Nson
Have the following form: %= simple_form_for @user, :as = :user, :action = edit_notification do |f| -% %= f.input :email % %= f.input :email_alerts % %= f.input :email_summarize % %= f.input

[Rails] accepts_nested_attributes_for and _destroy not working (but no error messages)

2011-04-14 Thread Niklas Nson
I have a has_many association and does some adding throug a nested form, i can add objects (images) and edit text this works fine. But when i try to delete items nothing happens. This is what my log looks like: Started POST /photosets/168 for 127.0.0.1 at Fri Apr 15 07:34:04 +0200 2011

[Rails] Re: Can't get .js.erb to work ...

2011-02-23 Thread Niklas Nson
Does not match :controller(/:action(/:id(.:format))) do the routing ? I thought it should look in controller and if not found look in public/ javascript ? //Niklas On 23 Feb, 14:05, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Tue, Feb 22, 2011 at 8:33 PM, Niklas Nson niklasn

[Rails] Re: Can't get .js.erb to work ...

2011-02-23 Thread Niklas Nson
Hassan, you are my hero Thank you for taking time ... Got it working :) /Niklas On 23 Feb, 14:25, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Wed, Feb 23, 2011 at 5:17 AM, Niklas Nson niklasn...@meantime.se wrote: Does not match :controller(/:action(/:id(.:format))) do

[Rails] Re: Can't get .js.erb to work ...

2011-02-22 Thread Niklas Nson
That gives me the error (in firebug) illegal XML character [Stop on error] var states = %= @states.collect {|st...ountry_id, h(state.name)]}.to_json % On 22 Feb, 08:22, Jim Ruther Nill jvn...@gmail.com wrote: On Tue, Feb 22, 2011 at 2:53 PM, Niklas Nson niklasn...@meantime.se wrote: Trying

[Rails] Re: Can't get .js.erb to work ...

2011-02-22 Thread Niklas Nson
:controller(/:action(/:id(.:format))) Do i need to do some other configs ? On 22 Feb, 16:47, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Tue, Feb 22, 2011 at 12:05 AM, Niklas Nson niklasn...@meantime.se wrote: That gives me the error (in firebug) illegal XML character [Stop

[Rails] Re: Can't get .js.erb to work ...

2011-02-22 Thread Niklas Nson
...@gmail.com wrote: On Tue, Feb 22, 2011 at 12:05 AM, Niklas Nson niklasn...@meantime.se wrote: That gives me the error (in firebug) illegal XML character [Stop on error] var states = %= @states.collect {|st...ountry_id, h(state.name)]}.to_json % If that's what the client is seeing, it would

[Rails] Re: Can't get .js.erb to work ...

2011-02-22 Thread Niklas Nson
= State.find(:all) @citys = City.find(:all) end end //Niklas On 22 Feb, 20:25, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Tue, Feb 22, 2011 at 10:51 AM, Niklas Nson niklasn...@meantime.se wrote: Yes i also belive that it dosent fire up. If i go to : http://localhost:3000

[Rails] Can't get .js.erb to work ...

2011-02-21 Thread Niklas Nson
Trying to follow railscast #88, i know the js.erb file is loaded but when i try to insert ruby code in the .js.erb file i get an error illegal XML character i have added the following line to my routes file match :controller(/:action(/:id(.:format))) and code not working is: ... var

[Rails] Need som help where to look, has_many or ?

2011-01-24 Thread Niklas Nson
I would need some help on pointing me to the correct direction. In application i would like users to be abel to select genres for work they like to do. A user can be willing to do a lot of genres or just one. If i still was writing code in .NET i would do a string of id's and then save them to the

[Rails] Re: Please advise on render:partial form.

2011-01-14 Thread Niklas Nson
Thanks, will have a look @ polymorphic associations, looks like what i want! If i can get it to work. Thanks again! /Niklas. On 13 Jan, 18:15, Arailsdemo A. li...@ruby-forum.com wrote: Looks like you have Casting has_many :comments, and you have a comment form on your Casting show page. If so,

[Rails] Please advise on render:partial form.

2011-01-13 Thread Niklas Nson
Background: On my application users can post Castings [class Casting] now i want other users to be abel to post Comments on the Castings [Castingcomment]. Approach: views/castings/show.html.erb ' %= render :partial = 'castingcomment_form' % app/controllers/castingcomments_controller.rb