Posts

ruby on rails - NoMethodError: undefined method `each' for # -

ruby on rails - NoMethodError: undefined method `each' for #<State:0x438a110> - 1. country=country.create(:name=>'australia') 2. country.states #<activerecord::associations::collectionproxy []> 3. first_state=state.new(:name=>'queensland') => #<state id: nil, country_id: nil, name: "queensland", created_at: nil, update d_at: nil> 4. first_state.country => nil 5.country.states=first_state **nomethoderror: undefined method `each' #<state:0x438a110>** in model: class state < activerecord::base belongs_to :country class country < activerecord::base has_many :states i new in rails. trying set country_id it's state, give me error. have done right think, still error occurs. please help me out. it's states (plural); it's expecting array country.states = [first_state] ruby-on-rails ruby-on-rails-4

Not able to connect multiple PostgreSQL database using SPRING +HIbernate -

Not able to connect multiple PostgreSQL database using SPRING +HIbernate - i need connect multiple postgresql database. using properties files database connection properties. when running application throwing error named query not found. when removing configuration sec database,every thing running fine.i have tried using catalog attribute of hibernate mapping. didnt yeild result. <bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="locations"> <list> <value>classpath:com/*****/config/jdbc.properties</value> <value>classpath:com/*****/config/userlogin.properties</value> </list> </property> <property name="ignoreunresolvableplaceholders" value="false"/> ...

c# - How to remove comma separated duplicated string values and get last two values -

c# - How to remove comma separated duplicated string values and get last two values - i want remove comma separated duplicate string values : string str = "2,4,3,12,25,2,4,3,6,2,2,2"; and want output this: string str1 = "6,2"; please tell how i'll self can't solve this a wild ride linq. there improve way, first 1 think of. string str = "2,4,3,12,25,2,4,3,6,2,2,2"; list<string> uniques = str.split(',').reverse().distinct().take(2).reverse().tolist(); string newstr = string.join(",", uniques); console.writeline(newstr); split string @ comma sequence apply reverse op, 2 2 2 6 .... 4 2 apply distinct, 2,6,3,4,25,12 take first 2 elements (2,6) reverse them 6,2 join in new string comma sep. c# asp.net string

sql - Before Update Trigger Issues -

sql - Before Update Trigger Issues - i'm trying create trigger accomplishes following examines value of field action_type in row having update requested if row (prior update) has action_type that's null, want insert value/string "change". if row (prior update) has action_type contains string 'add', want maintain value in-tact. if row (prior update) has action_type contains string 'change', want maintain value in-tact. create trigger tbl8_change on holiday_date_table before update begin if ((select action_type holiday_date_table inserted.hid = holiday_date_table.hid) == null) insert holiday_date_table (action_type) values ('changed') inserted.hid = holiday_date_table.hid; if ((select action_type holiday_date_table inserted.hid = holiday_date_table.hid) == 'changed') insert holiday_date_table (action_type) values ('changed') inserted.hid = holiday_date_table.hid; if ((select action_type holiday_date_ta...

jsf - Prevent selectBooleanCheckbox from changing value -

jsf - Prevent selectBooleanCheckbox from changing value - i have h:selectbooleancheckbox i'd validate within managed bean before allowing alter it's value. <h:selectbooleancheckbox id="attr" value="#{handler.attribute}" onclick="submit()" immediate="true" valuechangelistener="#{handler.changeattributevalue}" /> public string changeattributevalue(valuechangeevent event) { if(condition) attribute=false; homecoming "home"; } so i'd prevent attribute becoming true if status true. happens attribute set false @ first after method exits becomes true again. be careful immediate="true" . submitted value won't taken attribute remain in component model of selectbooleancheckbox - component, box checked 1 time again next time. seek immediate=false . sure, managed bean @sessionscoped , otherwise forget attribute reload/redirect page. even more handsome: <h...

Output a "advanced-custom-fields"-field programmatically in wordpress backend -

Output a "advanced-custom-fields"-field programmatically in wordpress backend - i created custom field "advanced-custom-fields"-plugin. want , output custom field programmatically in template file (backend, edit page), because template called via ajax if user want's add together new part page. is there function returns finish field? found functions gave me values, not field "form". i found solution. duplicated plugin folder theme root directory , set next code functions.php: function relationshipfield() { $newfield = new acf_field_relationship(); $field = array( 'post_type' => array('post'), 'max' => '', 'taxonomy' => array('all'), 'filters' => array('search'), 'res...

railscasts - rack::offline in rails 4.1 Issue -

railscasts - rack::offline in rails 4.1 Issue - can give me quick solution please? have done this: routes: offline = rack::offline.configure cache actioncontroller::base.helpers.asset_path("application.css") cache actioncontroller::base.helpers.asset_path("application.js") cache actioncontroller::base.helpers.asset_path("jquery.min.css") cache actioncontroller::base.helpers.asset_path("jquery.tmpl.min.css") cache actioncontroller::base.helpers.asset_path("style.js") # cache actioncontroller::base.helpers.asset_path("custom.css") network "/" end "/application.manifest" => offline in application.html.erb: <html manifest="/application.manifest"> in gemfile: # gem 'rack-offline' # gem 'rack-offline', :github => 'pascalw/rack-offline' gem 'rack-offline', :git => 'https://github.com/wycats/rack-off...